[Botan-devel] RSA removes spaces from my text

Z. S. O. tiredashell at gmail.com
Thu Jan 22 10:08:24 EST 2009


I have a fairly simple function below that uses RSA to encrypted a given
string. Strangely, if I encrypt a string with spaces and decrypt it, the
result is the same string with all spaces removed. For example, "Hello
World!" will result in "HelloWorld!". Any particular reason for this?

string EncryptRequest (string publicKey, string str)
{
AutoSeeded_RNG rng;
auto_ptr<X509_PublicKey> loadedPublicKey(X509::load_key(publicKey));
RSA_PublicKey* publicRSAKey =
dynamic_cast<RSA_PublicKey*>(loadedPublicKey.get());
auto_ptr<PK_Encryptor> encryptor(get_pk_encryptor(*publicRSAKey,
"EME1(SHA-1)"));

SecureVector<byte> encryptedString = encryptor->encrypt(b64_decode(str),
rng);
return b64_encode(encryptedString);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20090122/bf844480/attachment.html>


More information about the botan-devel mailing list