Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2022
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. (defun encrypt (byte-list &optional (key 55665) (n 4) (c1 52845) (c2 22719))
  2. (loop :for byte :in (append (loop repeat n collect (random #xFF))
  3. byte-list)
  4. :for r := key :then (mod (+ c2 (* c1 (+ cipher R)))#xFFFF)
  5. :for cipher := (logxor byte (ash R -8))
  6. :collect cipher))
  7.  
  8. To Encrypt a Sequence of Plaintext Bytes to Produce a
  9. Sequence of Ciphertext Bytes
  10. 1. Generate n random bytes to be additional plaintext bytes at
  11. the beginning of the sequence of plaintext bytes, for some
  12. value of n.
  13. 2. Initialize an unsigned 16-bit integer variable R to the encryp-
  14. tion key.
  15. 3. For each 8-bit byte, P, of plaintext (beginning with the newly
  16. added random bytes) execute the following steps:
  17. a. Assign the high order 8 bits of R to a temporary variable, T.
  18. b. Exclusive-OR P with T, producing a ciphertext byte, C.
  19. c. Compute the next value of R by the formula ((C + R) × c1 +
  20. c2) mod 65536, where c1 is 52845 (decimal) and c2 is 22719
  21. (decimal).
  22. This encryption step can be performed by the following C lan-
  23. guage program, where r is initialized to the key for the encryption
  24. type:
  25. unsigned short int r;
  26. unsigned short int c1 = 52845;
  27. unsigned short int c2 = 22719;
  28. unsigned char Encrypt(plain) unsigned char plain;
  29. {unsigned char cipher;
  30. cipher = (plain ^ (r>>8));
  31. r = (cipher + r) * c1 + c2;
  32. return cipher;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement