Skip to main content

decrypt

Function decrypt 

Source
pub fn decrypt(cipher: &[u8], seed: u16, skip: usize) -> Vec<u8> 
Expand description

Decrypt cipher with seed, dropping the first skip plaintext bytes.

A skip larger than the plaintext yields an empty result rather than panicking — a lenIV of 16 against a 3-byte charstring is a real thing broken fonts do.

use pdfrum_type1::{decrypt, CHARSTRING_SEED};

// Round-trip: encrypting then decrypting with the same seed is identity.
let plain = b"\0\0\0\0hsbw-ish payload";
let cipher = pdfrum_type1::encrypt(plain, CHARSTRING_SEED);
assert_eq!(decrypt(&cipher, CHARSTRING_SEED, 4), b"hsbw-ish payload");