DES library
Data encryption standard
Brief
DES encrypt algorithm is Symmetric encryption.DES encryption library using c++ implement.When use in your project only include header file,and use public method.
How to use
DES.hpp & fileDES.hpp in src dictionary
- include"DES.hpp" Original encrypt library
- include"fileDES.hpp" File encrypt library
DES:public function
DES is a static class, straightly use its public function.
-
encrypt :
- @param: in,key (bitset<64>) 64bitset input and cipher
- @return: ciphertext (bitset<64>) 64bitset result
-
decrypt :
- @param: ciphertext ,key (bitset<64>) 64bitset ciphertext and cipher
- @return: result (bitset<64>) 64bitset result
-
toString :
- @brief: translate from bitset<64> to hexadecimal format
- @param: in (bitset<64>) 64bitset input
- @return: result (string)
fileDES:public function
FileDES is a common class,need an instance to use it.
-
setInput
- @brief: set input filepath and open it
- @param: filepath(string)
- @return: void
-
setOutput
- @brief: set output filepath and mode and open it
- @param: filepath(string), mode = 0 encrypt,mode = 1 decrypt.
- @return: void
-
setKey
- @brief: set cipher
- @param: cipher(string)
-
encryptFile
- @brief: encrypt input file and get ciphertext in output file
-
decryptFile
- @brief: decrypt input file and get source file in output file
Example
FileDES des;
des.setInput("../data/input.txt"); ///your input file path
des.setOutput("../data/encrypt.txt",0); ///your encrypt output file path
des.setKey("123456"); ///your key
des.encryptFile(); ///encrypt file
des.setOutput("../data/decrypt.txt",1); ///your decrypt output file path
des.decryptFile(); ///decrypt file
Reference
DATA ENCRYPTION STANDARD (DES) fips-46-3