Objective c 加密++;静脉注射怎么办

Objective c 加密++;静脉注射怎么办,objective-c,cryptography,initialization-vector,Objective C,Cryptography,Initialization Vector,所以我尝试在Objective-C项目中使用Crypto++的加密。 如何处理静脉注射的问题?我试着把它预先附加到密文中。但是我在恢复它进行解密时遇到了一个问题 代码如下: - (NSString *)encryptUsingSerpentWithPlaintext:(NSString *)plaintext andKey:(NSData *)keyData { std::string ptext = [plaintext UTF8String]; std::string cip

所以我尝试在Objective-C项目中使用Crypto++的加密。 如何处理静脉注射的问题?我试着把它预先附加到密文中。但是我在恢复它进行解密时遇到了一个问题

代码如下:

- (NSString *)encryptUsingSerpentWithPlaintext:(NSString *)plaintext andKey:(NSData *)keyData
{
    std::string ptext = [plaintext UTF8String];
    std::string ciphertext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    CryptoPP::AutoSeededX917RNG<CryptoPP::Serpent> rng;
    rng.GenerateBlock(iv, CryptoPP::Serpent::BLOCKSIZE);

    std::string ivs(reinterpret_cast<char const *>(iv));
    lcl_log(lcl_cCrypto, lcl_vDebug, @"Random IV:%s",ivs.c_str());


    ::memcpy(key, keyData.bytes, keyData.length);


    CryptoPP::Serpent::Encryption serpentEncryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor (serpentEncryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor, new CryptoPP::StringSink (ciphertext));
    stfSerpentEncryptor.Put( reinterpret_cast<const unsigned char*>( ptext.c_str() ), ptext.length() + 1);
    stfSerpentEncryptor.MessageEnd();

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded ciphertext [size:%lu]:%s",sizeof(ciphertext),ciphertext.c_str());

    std::string finalCT;

    ciphertext = ivs + ciphertext; // add the IV before the ciphertext

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded iv+ciphertext [size:%lu]:%s",sizeof(ciphertext),ciphertext.c_str());

    CryptoPP::StringSource base64Encoder (ciphertext, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(finalCT)));

    // apply HMAC
    // TO DO

    NSString *cryptogram = [NSString stringWithUTF8String:finalCT.c_str()];

    return cryptogram;
}

- (NSString *)decryptUsingSerpentWithCiphertext:(NSString *)ciphertext andKey:(NSData *)keyData
{
    std::string ctext;
    std::string plaintext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    ::memcpy(key, keyData.bytes, keyData.length);

    // decode from base64
    std::string encoded = [ciphertext UTF8String];
    CryptoPP::StringSource base64Decoder (encoded, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(ctext)));

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded iv+ciphertext [size:%lu]:%s",sizeof(ctext),ctext.c_str());

    // get the IV from the beggining of the cryptogram
    std::string ivs = ctext.substr(0,CryptoPP::Serpent::BLOCKSIZE+5);

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Recovered IV:%s",ivs.c_str());

    ::memcpy(iv, &ivs, ivs.size());

    // remove the IV from the cryptogram

    ctext.erase(0,CryptoPP::Serpent::BLOCKSIZE+5);

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded ciphertext [size:%lu]:%s",sizeof(ctext),ctext.c_str());


    CryptoPP::Serpent::Decryption serpentDecryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcSerpentDecryptor (serpentDecryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentDecryptor(cbcSerpentDecryptor, new CryptoPP::StringSink (plaintext));
    stfSerpentDecryptor.Put( reinterpret_cast<const unsigned char*>( ctext.c_str() ), ctext.length());
    stfSerpentDecryptor.MessageEnd();

    NSString *plainText = [NSString stringWithUTF8String:plaintext.c_str()];

    return plainText;
}
日志将显示密文中仍有大量IV字节,并生成“无效密文,大小不是块大小的倍数”异常

日志:

2013-12-01 17:59:37.747应用程序[413:70b]D加密:PSCryptoCore.mm:51:-[PSCryptoCore测试蛇加密机制]初始明文:蛇形和黑色。。。

2013-12-01 17:59:37.748 App[413:70b]D Crypto:PSCryptoCore.mm:74:-[PSCryptoCore EncryptingusingSerpentswithplaintext:andKey:]Random IV:çìùËß,预先设置IV是完全正确的。为什么要在块大小上增加5?从Base-64解码为数据。将第一个BLOCKSIZE字节从IV中取出。解密剩余的。

预结束IV完全正确。为什么要在块大小上增加5?从Base-64解码为数据。将第一个BLOCKSIZE字节从IV中取出。解密剩余的。

我设法修复了它。 这是密码

- (NSString *)encryptUsingSerpentWithPlaintext:(NSString *)plaintext andKey:(NSData *)keyData
{
    std::string ptext = [plaintext UTF8String];
    std::string ciphertext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    CryptoPP::AutoSeededX917RNG<CryptoPP::Serpent> rng;
    rng.GenerateBlock(iv, CryptoPP::Serpent::BLOCKSIZE);

    std::string ivs(reinterpret_cast<char const *>(iv));
    lcl_log(lcl_cCrypto, lcl_vDebug, @"Random IV:%s",ivs.c_str());


    ::memcpy(key, keyData.bytes, keyData.length);


    CryptoPP::Serpent::Encryption serpentEncryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor (serpentEncryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor, new CryptoPP::StringSink (ciphertext),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentEncryptor.Put( reinterpret_cast<const unsigned char*>( ptext.c_str() ), ptext.length() + 1);
    stfSerpentEncryptor.MessageEnd();

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded ciphertext [size:%lu]:%s",sizeof(ciphertext),ciphertext.c_str());

    std::string finalCT;

    CryptoPP::StringSource base64Encoder (ciphertext, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(finalCT)));

    std::string ivB64;

    CryptoPP::StringSource base64IVEncoder (ivs , true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(ivB64)));

    lcl_log(lcl_cCrypto, lcl_vDebug, @"IV base64[size:%lu]:%s",ivB64.length(),ivB64.c_str());

    finalCT = ivB64 + finalCT;

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Cryptogram:%s",finalCT.c_str());

    // apply HMAC
    // TO DO

    NSString *cryptogram = [NSString stringWithUTF8String:finalCT.c_str()];

    return cryptogram;
}

- (NSString *)decryptUsingSerpentWithCiphertext:(NSString *)ciphertext andKey:(NSData *)keyData
{
    std::string ctext;
    std::string plaintext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    ::memcpy(key, keyData.bytes, keyData.length);

    // decode from base64
    std::string encoded = [ciphertext UTF8String];

    // pull IV from ciphertext
    std::string ivs = encoded.substr(0,29);
    encoded.erase(0,29);

    CryptoPP::StringSource base64Decoder (encoded, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(ctext)));

    std::string iv_tmp;
    CryptoPP::StringSource base64IVDecoder (ivs, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(iv_tmp)));



    lcl_log(lcl_cCrypto, lcl_vDebug, @"Recovered IV[encoded]:%s",ivs.c_str());

    ::memcpy(iv, iv_tmp.data(), CryptoPP::Serpent::BLOCKSIZE);



    CryptoPP::Serpent::Decryption serpentDecryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcSerpentDecryptor (serpentDecryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentDecryptor(cbcSerpentDecryptor, new CryptoPP::StringSink (plaintext), CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentDecryptor.Put( reinterpret_cast<const unsigned char*>( ctext.c_str() ), ctext.length());
    stfSerpentDecryptor.MessageEnd();

    NSString *plainText = [NSString stringWithUTF8String:plaintext.c_str()];

    return plainText;
}
-(NSString*)加密使用serpenth纯文本:(NSString*)纯文本和密钥:(NSData*)密钥数据
{
std::string ptext=[纯文本UTF8String];
字符串密文;
字节键[CryptoPP::Serpent::MAX_KEYLENGTH],iv[CryptoPP::Serpent::BLOCKSIZE];
CryptoPP::AutoseedX917RNG rng;
rng.GenerateBlock(iv,CryptoPP::Serpent::BLOCKSIZE);
标准:字符串iv(重新解释铸型(iv));
lcl_日志(lcl_cCrypto,lcl_vDebug,@“随机IV:%s”,ivs.c_str());
::memcpy(key,keyData.bytes,keyData.length);
CryptoPP::Serpent::Encryption Serpent Encryptor(密钥,CryptoPP::Serpent::MAX_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor(蛇式加密机,iv);
CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor,新CryptoPP::StringSink(密文),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::1和0填充);
stfSerpentEncryptor.Put(reinterpret_cast(ptext.c_str()),ptext.length()+1);
stfSerpentEncryptor.MessageEnd();
lcl_日志(lcl_cCrypto,lcl_vDebug,@“非编码密文[大小:%lu]:%s”,sizeof(密文),ciphertext.c_str());
std::字符串finalCT;
CryptoPP::StringSource base64Encoder(密文,true,新CryptoPP::base64Encoder(新CryptoPP::StringSink(finalCT));
std::字符串ivB64;
CryptoPP::StringSource base64IVEncoder(ivs,true,新的CryptoPP::Base64Encoder(新的CryptoPP::StringSink(ivB64));
lcl_日志(lcl_cCrypto,lcl_vDebug,@“IV base64[大小:%lu]:%s”,ivB64.length(),ivB64.c_str());
finalCT=ivB64+finalCT;
lcl_日志(lcl_cCrypto,lcl_vDebug,@“密码:%s”,finalCT.c_str());
//应用HMAC
//做
NSString*密码=[NSString stringWithUTF8String:finalCT.c_str()];
返回密码;
}
-(NSString*)使用带密文的蛇解密:(NSString*)密文和密钥:(NSData*)密钥数据
{
std::字符串ctext;
std::字符串纯文本;
字节键[CryptoPP::Serpent::MAX_KEYLENGTH],iv[CryptoPP::Serpent::BLOCKSIZE];
::memcpy(key,keyData.bytes,keyData.length);
//从base64解码
std::string encoded=[密文UTF8String];
//从密文中提取IV
std::stringivs=encoded.substr(0,29);
编码。擦除(0,29);
CryptoPP::StringSource Base64解码器(编码的、真的、新的CryptoPP::Base64解码器(新的CryptoPP::StringSink(ctext));
标准:字符串iv_tmp;
CryptoPP::StringSource base64IVDecoder(ivs,true,新CryptoPP::Base64Decoder(新CryptoPP::StringSink(iv_tmp));
lcl_日志(lcl_cCrypto,lcl_vDebug,@“恢复的IV[编码]:%s”,ivs.c_str());
::memcpy(iv,ivtmp.data(),CryptoPP::Serpent::BLOCKSIZE);
CryptoPP::蛇::解密蛇解密器(密钥,CryptoPP::蛇::最大密钥长度);
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcSerpentDecryptor(蛇形解密器,iv);
CryptoPP::StreamTransformationFilter stfSerpentDecryptor(cbcSerpentDecryptor,新的CryptoPP::StringSink(纯文本),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::1和0填充);
stfSerpentDecryptor.Put(reinterpret_cast(ctext.c_str()),ctext.length());
stfSerpentDecryptor.MessageEnd();
NSString*明文=[NSString stringWithUTF8String:plainText.c_str()];
返回纯文本;
}
我注意到Base64中的IV长度为29。。。我不确定情况是否总是这样。。可能是因为其他16字节IV的base64字符串的长度不同吗?

我设法解决了这个问题。 这是密码

- (NSString *)encryptUsingSerpentWithPlaintext:(NSString *)plaintext andKey:(NSData *)keyData
{
    std::string ptext = [plaintext UTF8String];
    std::string ciphertext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    CryptoPP::AutoSeededX917RNG<CryptoPP::Serpent> rng;
    rng.GenerateBlock(iv, CryptoPP::Serpent::BLOCKSIZE);

    std::string ivs(reinterpret_cast<char const *>(iv));
    lcl_log(lcl_cCrypto, lcl_vDebug, @"Random IV:%s",ivs.c_str());


    ::memcpy(key, keyData.bytes, keyData.length);


    CryptoPP::Serpent::Encryption serpentEncryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor (serpentEncryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor, new CryptoPP::StringSink (ciphertext),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentEncryptor.Put( reinterpret_cast<const unsigned char*>( ptext.c_str() ), ptext.length() + 1);
    stfSerpentEncryptor.MessageEnd();

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded ciphertext [size:%lu]:%s",sizeof(ciphertext),ciphertext.c_str());

    std::string finalCT;

    CryptoPP::StringSource base64Encoder (ciphertext, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(finalCT)));

    std::string ivB64;

    CryptoPP::StringSource base64IVEncoder (ivs , true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(ivB64)));

    lcl_log(lcl_cCrypto, lcl_vDebug, @"IV base64[size:%lu]:%s",ivB64.length(),ivB64.c_str());

    finalCT = ivB64 + finalCT;

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Cryptogram:%s",finalCT.c_str());

    // apply HMAC
    // TO DO

    NSString *cryptogram = [NSString stringWithUTF8String:finalCT.c_str()];

    return cryptogram;
}

- (NSString *)decryptUsingSerpentWithCiphertext:(NSString *)ciphertext andKey:(NSData *)keyData
{
    std::string ctext;
    std::string plaintext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    ::memcpy(key, keyData.bytes, keyData.length);

    // decode from base64
    std::string encoded = [ciphertext UTF8String];

    // pull IV from ciphertext
    std::string ivs = encoded.substr(0,29);
    encoded.erase(0,29);

    CryptoPP::StringSource base64Decoder (encoded, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(ctext)));

    std::string iv_tmp;
    CryptoPP::StringSource base64IVDecoder (ivs, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(iv_tmp)));



    lcl_log(lcl_cCrypto, lcl_vDebug, @"Recovered IV[encoded]:%s",ivs.c_str());

    ::memcpy(iv, iv_tmp.data(), CryptoPP::Serpent::BLOCKSIZE);



    CryptoPP::Serpent::Decryption serpentDecryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcSerpentDecryptor (serpentDecryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentDecryptor(cbcSerpentDecryptor, new CryptoPP::StringSink (plaintext), CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentDecryptor.Put( reinterpret_cast<const unsigned char*>( ctext.c_str() ), ctext.length());
    stfSerpentDecryptor.MessageEnd();

    NSString *plainText = [NSString stringWithUTF8String:plaintext.c_str()];

    return plainText;
}
-(NSString*)加密使用serpenth纯文本:(NSString*)纯文本和密钥:(NSData*)密钥数据
{
std::string ptext=[纯文本UTF8String];
字符串密文;
字节键[CryptoPP::Serpent::MAX_KEYLENGTH],iv[CryptoPP::Serpent::BLOCKSIZE];
CryptoPP::AutoseedX917RNG rng;
rng.GenerateBlock(iv,CryptoPP::Serpent::BLOCKSIZE);
标准:字符串iv(重新解释铸型(iv));
lcl_日志(lcl_cCrypto,lcl_vDebug,@“随机IV:%s”,ivs.c_str());
::memcpy(key,keyData.bytes,keyData.length);
CryptoPP::Serpent::Encryption Serpent Encryptor(密钥,CryptoPP::Serpent::MAX_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor(蛇式加密机,iv);
CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor,新CryptoPP::StringSink(密文),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::1和0填充);
stfSerpentEncryptor.Put(reinterpret_cast(ptext.c_str()),ptext.length()+1);
stfSerpentEncryptor.MessageEnd();
lcl_日志(lcl_cCrypto,lcl_vDebug,@“非编码密文[大小:%lu]:%s”,sizeof(密文),ciphertext.c_str());
std::字符串finalCT;
CryptoPP::StringSource base64Encoder(密文,true,新CryptoPP::base64Encoder(新CryptoPP::StringSink(finalCT));
std::字符串ivB64;
CryptoPP::StringSource base64IVE
- (NSString *)encryptUsingSerpentWithPlaintext:(NSString *)plaintext andKey:(NSData *)keyData
{
    std::string ptext = [plaintext UTF8String];
    std::string ciphertext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    CryptoPP::AutoSeededX917RNG<CryptoPP::Serpent> rng;
    rng.GenerateBlock(iv, CryptoPP::Serpent::BLOCKSIZE);

    std::string ivs(reinterpret_cast<char const *>(iv));
    lcl_log(lcl_cCrypto, lcl_vDebug, @"Random IV:%s",ivs.c_str());


    ::memcpy(key, keyData.bytes, keyData.length);


    CryptoPP::Serpent::Encryption serpentEncryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcSerpentEncryptor (serpentEncryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentEncryptor(cbcSerpentEncryptor, new CryptoPP::StringSink (ciphertext),CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentEncryptor.Put( reinterpret_cast<const unsigned char*>( ptext.c_str() ), ptext.length() + 1);
    stfSerpentEncryptor.MessageEnd();

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Non-Encoded ciphertext [size:%lu]:%s",sizeof(ciphertext),ciphertext.c_str());

    std::string finalCT;

    CryptoPP::StringSource base64Encoder (ciphertext, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(finalCT)));

    std::string ivB64;

    CryptoPP::StringSource base64IVEncoder (ivs , true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(ivB64)));

    lcl_log(lcl_cCrypto, lcl_vDebug, @"IV base64[size:%lu]:%s",ivB64.length(),ivB64.c_str());

    finalCT = ivB64 + finalCT;

    lcl_log(lcl_cCrypto, lcl_vDebug, @"Cryptogram:%s",finalCT.c_str());

    // apply HMAC
    // TO DO

    NSString *cryptogram = [NSString stringWithUTF8String:finalCT.c_str()];

    return cryptogram;
}

- (NSString *)decryptUsingSerpentWithCiphertext:(NSString *)ciphertext andKey:(NSData *)keyData
{
    std::string ctext;
    std::string plaintext;

    byte key[ CryptoPP::Serpent::MAX_KEYLENGTH ], iv[ CryptoPP::Serpent::BLOCKSIZE ];

    ::memcpy(key, keyData.bytes, keyData.length);

    // decode from base64
    std::string encoded = [ciphertext UTF8String];

    // pull IV from ciphertext
    std::string ivs = encoded.substr(0,29);
    encoded.erase(0,29);

    CryptoPP::StringSource base64Decoder (encoded, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(ctext)));

    std::string iv_tmp;
    CryptoPP::StringSource base64IVDecoder (ivs, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(iv_tmp)));



    lcl_log(lcl_cCrypto, lcl_vDebug, @"Recovered IV[encoded]:%s",ivs.c_str());

    ::memcpy(iv, iv_tmp.data(), CryptoPP::Serpent::BLOCKSIZE);



    CryptoPP::Serpent::Decryption serpentDecryptor (key, CryptoPP::Serpent::MAX_KEYLENGTH);
    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcSerpentDecryptor (serpentDecryptor, iv);

    CryptoPP::StreamTransformationFilter stfSerpentDecryptor(cbcSerpentDecryptor, new CryptoPP::StringSink (plaintext), CryptoPP::StreamTransformationFilter::BlockPaddingScheme::ONE_AND_ZEROS_PADDING);
    stfSerpentDecryptor.Put( reinterpret_cast<const unsigned char*>( ctext.c_str() ), ctext.length());
    stfSerpentDecryptor.MessageEnd();

    NSString *plainText = [NSString stringWithUTF8String:plaintext.c_str()];

    return plainText;
}