Java public private key decryption issue?

If you look at this page ( wikijava.org/wiki/Secret_Key_Cryptograph... ) you will need to do base-64 encoding to turn the bytes into a string, then to decrypt it you would just decode it then decrypt.

If you look at this page (wikijava.org/wiki/Secret_Key_Cryptograph...) you will need to do base-64 encoding to turn the bytes into a string, then to decrypt it you would just decode it then decrypt. Base-64 encoding uses the first 7 bits of a byte, to make something that is printable or emailable, for example. UPDATE: I made a mistake, there are 64 characters that it would be encoded in, again, in order to make it easier to use as something printable.

Downvoted because this is misleading/correct. If the OP were willing to work with byte arrays, base64 encoding is not necessary. And also, "uses the first 7 bits of a byte" is not at all how base64 works.En.wikipedia.Org/wiki/Base64#Examples – Jumbogram Mar 19 at 2:31 @Jumbogram - OK, 64 characters, I will correct that, but I expect the test is to go from encrypt to string (for saving to a file) then decrypt that.

Base-64 is the best bet. – James Black Mar 19 at 2:33.

(I know it seems like a question, but it's actually an answer...).

Perhaps you could point out why this could cause problems – Jumbogram Mar 19 at 2:34 The encryption will make more than half of the bytes (in average) unreadble or even with no matching ascii symbol, the decrypted message should be readable just like the original message, so it should be converted to string again with no problems. Also, since the calls to decrypt and encrypt are done with byte I see no reason to convert it twice again in the middle. – MByD Mar 19 at 2:51 I want to correct my previous comment.

There might be plenty of reasons to convert it to String in the middle, but in general, I think it should be avoided. – MByD Mar 19 at 2:59 If you want to encrypt, then send an email, are you going to do it as an attachment? If you want to include the message as part of an xml file bytes can be a difficulty.It is generally easier to convert to a string, get it where it needs to be, then just go back to bytes.

– James Black Mar 19 at 16:20 @James Black - I get your point, you're right. – MByD Mar 19 at 19:44.

Using RSA directly on unformatted data may leave your application vulnerable to an adaptive chosen ciphertext attack. For details please see Chapter 8, pages 288-289, of the Handbook of Applied Cryptography, a freely-available book from CRC Press. (It's well worth buying the bound edition, if you're really interested in cryptography -- you'll be stunned at the quality for the price.) Because of this attack, most protocols that integrate RSA use RSA for encrypting randomly-generated session keys or signing hash functions with outputs that ought to be indistinguishable from random, OR using very carefully formatted messages that will fail to be correctly interpreted.

(See Note 8.63 in HAC for details. ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions