Poco::Crypto--加解密(RSA)
2012-09-04 16:32
232 查看
1、简单的加解密
2、用公私钥加解密
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL)); std::string val("I love karen!"); std::string enc = pCipher->encryptString(val); std::string dec = pCipher->decryptString(enc); std::cout<<"加密后:"<<enc<<std::endl; std::cout<<"解密后:"<<dec<<std::endl;
2、用公私钥加解密
std::istringstream str(anyPem); X509Certificate cert(str); RSAKey publicKey(cert); std::istringstream str2(anyPem); RSAKey privateKey(0, &str2, "test"); Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(publicKey); Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(privateKey); std::string val("lets do some encryption"); std::string enc = pCipher->encryptString(val); std::string dec = pCipher2->decryptString(enc); std::cout<<"加密后:"<<enc<<std::endl; std::cout<<"解密后:"<<dec<<std::endl;
相关文章推荐
- Poco::Crypto--加解密(AES)
- 基于Crypto++/Cryptopp的rsa密钥生成,rsa加密、解密,rsa签名、验签
- javax.crypto.BadPaddingException: Blocktype mismatch: 0 RSA加密,Android到服务器解密报错
- node.js 使用crypto模块进行RSA加解密操作
- 基于Crypto++/Cryptopp的rsa密钥生成,rsa加密、解密,rsa签名、验签
- 基于Crypto++/Cryptopp的rsa密钥生成,rsa加密、解密,rsa签名、验签12
- RSA解密时javax.crypto.BadPaddingException: Data must start with zero
- 基于Crypto++/Cryptopp的rsa密钥生成,rsa加密、解密,rsa签名、验签
- 使用Crypto++5.5.2完成RSA加解密,真正的把公钥放在字符串内,而不是放在文件内
- as3 crypto 加密解密des,rsa
- RSA 加密解密 关于javax.crypto.BadPaddingException: Blocktype错误的几种解决方法
- Python开发【模块】:M2Crypto RSA加密、解密
- 基于Crypto++/Cryptopp的rsa密钥生成,rsa加密、解密,rsa签名、验签12
- 关于解决RSA非对称加密时,将密文存入数据库取出后,再对密文解密的时候抛出javax.crypto.BadPaddingException: Data must start with zero
- 用openssl库RSA加密解密
- Android安全之非对称加密RSA密钥生成、加密、解密
- JS下RSA加解密
- Java使用RSA加密解密签名及校验
- C#RSA非对称加解密
- Android RSA加密,解密