本文整理汇总了C++中cipher::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: testRSACipherLarge
void RSATest::testRSACipherLarge()
{
std::vector<std::size_t> sizes;
sizes.push_back (2047);
sizes.push_back (2048);
sizes.push_back (2049);
sizes.push_back (4095);
sizes.push_back (4096);
sizes.push_back (4097);
sizes.push_back (8191);
sizes.push_back (8192);
sizes.push_back (8193);
sizes.push_back (16383);
sizes.push_back (16384);
sizes.push_back (16385);
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
for (std::vector<std::size_t>::const_iterator it = sizes.begin(); it != sizes.end(); ++it)
{
std::string val(*it, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
}
}
开发者ID:as2120,项目名称:ZPoco,代码行数:25,代码来源:RSATest.cpp
示例2: testEncryptDecryptWithSalt
void CryptoTest::testEncryptDecryptWithSalt()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
Cipher::Ptr pCipher2 = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "simplepwd", "Too much salt"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher2->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher2->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
}
}
开发者ID:12307,项目名称:poco,代码行数:29,代码来源:CryptoTest.cpp
示例3: testDecryptInterop
void CryptoTest::testDecryptInterop()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256", "password", "salt"));
const std::string expectedPlainText = "This is a secret message.";
const std::string cipherText = "9HITTPaU3A/LaZzldbdnRZ109DKlshouKren/n8BsHc=";
std::string plainText = pCipher->decryptString(cipherText, Cipher::ENC_BASE64);
assert (plainText == expectedPlainText);
}
开发者ID:12307,项目名称:poco,代码行数:9,代码来源:CryptoTest.cpp
示例4: testRSACipher
void RSATest::testRSACipher()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(RSAKey(RSAKey::KL_1024, RSAKey::EXP_SMALL));
for (std::size_t n = 1; n <= 1200; n++)
{
std::string val(n, 'x');
std::string enc = pCipher->encryptString(val);
std::string dec = pCipher->decryptString(enc);
assert (dec == val);
}
}
开发者ID:as2120,项目名称:ZPoco,代码行数:11,代码来源:RSATest.cpp
示例5: testCertificate
void RSATest::testCertificate()
{
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);
assert (dec == val);
}
开发者ID:as2120,项目名称:ZPoco,代码行数:15,代码来源:RSATest.cpp
示例6: testEncryptDecryptDESECB
void CryptoTest::testEncryptDecryptDESECB()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("des-ecb", "password"));
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_NONE);
std::string result = pCipher->decryptString(out, Cipher::ENC_NONE);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BASE64);
std::string result = pCipher->decryptString(out, Cipher::ENC_BASE64);
assert (in == result);
}
for (std::size_t n = 1; n < MAX_DATA_SIZE; n++)
{
std::string in(n, 'x');
std::string out = pCipher->encryptString(in, Cipher::ENC_BINHEX);
std::string result = pCipher->decryptString(out, Cipher::ENC_BINHEX);
assert (in == result);
}
}
开发者ID:12307,项目名称:poco,代码行数:28,代码来源:CryptoTest.cpp
注:本文中的cipher::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论