本文整理汇总了C++中cipher::Ptr::decryptString方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::decryptString方法的具体用法?C++ Ptr::decryptString怎么用?C++ Ptr::decryptString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cipher::Ptr
的用法示例。
在下文中一共展示了Ptr::decryptString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testEncryptDecrypt
void CryptoTest::testEncryptDecrypt()
{
Cipher::Ptr pCipher = CipherFactory::defaultFactory().createCipher(CipherKey("aes256"));
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);
}
}
示例2: 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);
}
}
示例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);
}
示例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);
}
}