Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun encrypt (byte-list &optional (key 55665) (n 4) (c1 52845) (c2 22719))
- (loop :for byte :in (append (loop repeat n collect (random #xFF))
- byte-list)
- :for r := key :then (mod (+ c2 (* c1 (+ cipher R)))#xFFFF)
- :for cipher := (logxor byte (ash R -8))
- :collect cipher))
- To Encrypt a Sequence of Plaintext Bytes to Produce a
- Sequence of Ciphertext Bytes
- 1. Generate n random bytes to be additional plaintext bytes at
- the beginning of the sequence of plaintext bytes, for some
- value of n.
- 2. Initialize an unsigned 16-bit integer variable R to the encryp-
- tion key.
- 3. For each 8-bit byte, P, of plaintext (beginning with the newly
- added random bytes) execute the following steps:
- a. Assign the high order 8 bits of R to a temporary variable, T.
- b. Exclusive-OR P with T, producing a ciphertext byte, C.
- c. Compute the next value of R by the formula ((C + R) × c1 +
- c2) mod 65536, where c1 is 52845 (decimal) and c2 is 22719
- (decimal).
- This encryption step can be performed by the following C lan-
- guage program, where r is initialized to the key for the encryption
- type:
- unsigned short int r;
- unsigned short int c1 = 52845;
- unsigned short int c2 = 22719;
- unsigned char Encrypt(plain) unsigned char plain;
- {unsigned char cipher;
- cipher = (plain ^ (r>>8));
- r = (cipher + r) * c1 + c2;
- return cipher;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement