I agree, if you want to do this, use the sign/verify methods, they work
pretty much the same as the encryption/decryption.
Elias Önal wrote:
>
> Hey,
>
> why do you want to encrypt data using the private key? That process is
> usually known as "signing" and you should be really careful doing so. In
> some cases it might even break the algorithm when done wrong! *cough*
> ElGamal *cough* *cough*
>
> Greets Elias
>
> On 2/8/11 11:42 AM, Leo Mifare wrote:
>> Hi friends..
>>
>> i'm really confused how to encrypt data using PrivateKey , NO Padding,
>> and Decrypt it using PublicKey.
>> Hmm, actually i can solve this problem easily using Java..
>> But i want implement the process in my C++ application..
>>
>> *Snippet Code :*
>> byte[] inputEncryption =
>> ByteUtils.StringToHex("@ABCDEFGHIJKLMNO@ABCDEFGHIJKLMNO@ABCDEFGHIJKLMNO@ABCDEFGHIJKLMNO");
>>
>> //404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F
>>
>> Cipher rsaCipher2 = Cipher.getInstance("RSA/None/NoPadding");
>> RSAPublicKey myPubKEY = (RSAPublicKey)
>> KeyFactory.getInstance("RSA").generatePublic(rsaPublicKeySpec);
>> RSAPrivateKey myPrivKEY = (RSAPrivateKey)
>> KeyFactory.getInstance("RSA").generatePrivate(rsaPrivateKeySpec);
>> rsaCipher2.init(Cipher.ENCRYPT_MODE, myPrivKEY);
>> byte[] output = rsaCipher2.doFinal(inputEncryption);
>> System.out.println("OUTPUT Encryption = " +
>> ByteUtils.HexToString(output));
>>
>> rsaCipher2.init(Cipher.DECRYPT_MODE, myPubKEY);
>> output = rsaCipher2.doFinal(output);
>> System.out.println("OUTPUT = " + ByteUtils.HexToString(output));
>>
>> *Snippet Console Output :*
>> RSA Private Key Modulus =
>> 00A9C985E853C94ADDA1969486896B657257580E695C7C92AC891DCB4041C8552F6F30CC9B7CA97C1213E31C8C8985EFB475B5572B73BE4446077AC31E614DFA67
>> RSA Private Key Exponent =
>> 00806DDC69997F28AF2EFC7D0AAB45DE6DB81DF680C221C4BCD7D6FE987369FAEC73CB964D6E3F5C87BE3DBE8FE034FC96D13940E51EC4D82B791E84B334C951B9
>> Encrypted Data =
>> 903B72E6DA4BEB674670A7723E17CFE6D6CC0939BD4CD43166B49A10194B3AC08F3433C1CF2484CC25C233AEA9A958DBF128AA19D8555BD87BA618E497B414B9
>> Decrypted Data =
>> 404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F404142434445464748494A4B4C4D4E4F
>>
>> How to achieve that using Cryptopp
>>
>> Please help me regarding this..
>>
>> Sorry i'm pretty new in this field..
>>
>> Thanks
>> --
>> You received this message because you are subscribed to the "Crypto++
>> Users" Google Group.
>> To unsubscribe, send an email to
>> [email protected].
>> More information about Crypto++ and this group is available at
>> http://www.cryptopp.com.
>
> --
> You received this message because you are subscribed to the "Crypto++
> Users" Google Group.
> To unsubscribe, send an email to
> [email protected].
> More information about Crypto++ and this group is available at
> http://www.cryptopp.com.
>
--
View this message in context:
http://old.nabble.com/-Cryptopp5.1-How-to-solve-RSA-Encryption-using-PrivateKey-with-No-Padding--tp30872032p30879246.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.