Jump to content
  • Advertisement
Sign in to follow this  
gorgorath

[java] encryption problem

This topic is 4571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm wondering why the following doesn't work: Cipher encrypt = Cipher.getInstance("RSA"); encrypt.init(Cipher.ENCRYPT_MODE, key); ByteArrayInputStream str = new ByteArrayInputStream(data); CipherInputStream cis = new CipherInputStream(str, encrypt); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte tmp[] = new byte[8]; int i = cis.read(tmp); while (i != -1) { out.write(tmp, 0, i); i = cis.read(tmp); } //WORKS ALWAYS TILL 52 characthers //return encrypt.doFinal(data); //this DON"T WORK AL the times buyt sometimes does return out.toString().getBytes(); the doFinal method always works but only upto 52 bytes probably i'm overlooking sth. but can't see directly waht

Share this post


Link to post
Share on other sites
Advertisement
Wild guess, but is the key 52 charactors? if it's the same length as the key, then you need to make a loop to make sure it loops through the key as many times as necessary. That was a problem I had when I was writing some basic encryption in Turing for a programming contest, and I ran out of time..

But yeah, that could be the problem. (sorry I can't offer a solution, since I'm not used to encryption in Java and would code everything myself, i can't help with java's interface, it could just be that you need to encode each 52 character string one at a timeand out put them each time, ro something liek that)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!