跳到主要内容

X3M 解密算法

Rust 的参考实现:

参数:

  • content_key: 32 字节的密钥
  • scramble_table: 1024 个成员组成的数组,取值范围为 [0, 1024)
伪代码
fn encrypt(decrypted_header, content_key, scramble_table):
for encrypted_index in 0..1024:
decrypted_index = scramble_table.index_of(encrypted_index)

byte = decrypted_header[decrypted_index] XOR content_key[decrypted_index]
result << byte

fn decrypt(encrypted_header, content_key, scramble_table):
for decrypted_index in 0..1024:
encrypted_index = scramble_table[decrypted_index]

byte = encrypted_header[encrypted_index] XOR content_key[decrypted_index]
result << byte