README.rst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ###################
  2. DES in C
  3. ###################
  4. C implementation of Data Encryption Standard algorithm.
  5. Overview
  6. ========
  7. The Data Encryption Standard (DES) is a block cipher (a form of shared secret encryption) that was selected by the National
  8. Bureau of Standards as an official Federal Information Processing Standard (FIPS) for the United States in 1976 and which
  9. has subsequently enjoyed widespread use internationally. It is based on a symmetric-key algorithm that uses a 56-bit key.
  10. This implementation of DES is not optimized in any way. The code has been written to provide readability and easy
  11. understanding of the algorithm. Padding scheme used in this implementation is `[PKCS5] <ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-5v2/pkcs5v2-0.pdf>`_
  12. Compilation & Installation
  13. ==========================
  14. This implementation has only been tested on Unix platform. But you may be able to compile/ run it on Windows.
  15. 1. Make sure des.c, des.h and run_des.c are in the same directory
  16. 2. Compile using: gcc -O3 des.c run_des.c -o run_des.o
  17. Usage
  18. =====
  19. Say we want to encrypt/ decrypt a file named /home/user/sample.txt
  20. 1. Generate a keyfile using::
  21. run_des.o -g /tmp/keyfile.key
  22. 2. Encrypt sample.txt using::
  23. run_des.o -e /tmp/keyfile.key /home/user/sample.txt /home/user/sample.enc
  24. 3. Decrypt sample.txt using::
  25. run_des.o -d /tmp/keyfile.key /home/user/sample.enc /home/user/sample_decrypted.txt
  26. Don't lose the key file! you won't be able to decrypt an encrypted if you lose the keyfile.
  27. More
  28. ====
  29. DES is provided for educational purposes only. Do not use for any other reason.
  30. It has been implemented after `J. Orlin Grabbe's DES Algorithm Illustrated <http://orlingrabbe.com/des.htm>`_
  31. It is possible to use this implementation to facilitate TripleDES encryption process:
  32. 1. Generate keys using::
  33. run_des.o -g /tmp/keyfile1.key
  34. run_des.o -g /tmp/keyfile2.key
  35. run_des.o -g /tmp/keyfile3.key
  36. 2. Encrypt using::
  37. run_des.o -e /tmp/keyfile1.key /home/user/sample.txt /home/user/sample.enc1
  38. run_des.o -e /tmp/keyfile2.key /home/user/sample.enc1 /home/user/sample.enc2
  39. run_des.o -e /tmp/keyfile3.key /home/user/sample.enc2 /home/user/sample.enc3
  40. 3. Decrypt using::
  41. run_des.o -d /tmp/keyfile3.key /home/user/sample.enc3 /home/user/sample.dec3
  42. run_des.o -d /tmp/keyfile2.key /home/user/sample.dec3 /home/user/sample.dec2
  43. run_des.o -d /tmp/keyfile1.key /home/user/sample.dec2 /home/user/sample_decrypted.txt