crypto++使用DES加密(ECB pkcs7padding )
生活随笔
收集整理的這篇文章主要介紹了
crypto++使用DES加密(ECB pkcs7padding )
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
zeropadding
ZeroPadding,數據長度不對齊時使用0填充,否則不填充。使用0填充有個缺點,當元數據尾部也存在0時,在unpadding時可能會存在問題。
pkcs7padding
假設每個區塊大小為blockSize
<1>已對齊,填充一個長度為blockSize且每個字節均為blockSize的數據。
<2>未對齊,需要補充的字節個數為n,則填充一個長度為n且每個字節均為n的數據。
pkcs5padding
PKCS7Padding的子集,只是塊大小固定為8字節。
ECB 模式
//加密 string DES_encrypt(const char *key, string &content){string cipher;try{ECB_Mode<DES>::Encryption e;e.SetKey((const byte*)key, DES::KEYLENGTH);StringSource(content, true, new StreamTransformationFilter(e,new StringSink(cipher)));}catch (const Exception &e){cout << e.what() << endl;}return cipher; } //解密 string DES_decrypt(const char *key, string &cipher){string plain;try{ECB_Mode<DES>::Decryption e;e.SetKey((const byte*)key, DES::KEYLENGTH);StringSource(content, true, new StreamTransformationFilter(e,new StringSink(plain)));}catch (const Exception &e){cout << e.what() << endl;}return plain; }總結
以上是生活随笔為你收集整理的crypto++使用DES加密(ECB pkcs7padding )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: version.dll劫持注入模版
- 下一篇: ReadDirectoryChanges