0

What algorithm can I use for creating an encryption program in Java? What if I want to use the same key for encrypting and decrypting?

Example: I type Hello world and use the key guy, so the words change into xgdsts@dtoll. If I want to decrypt it, I have to use the same key(guy) so it'll become hello world again

3
  • 2
    Just to aid you when googling, what you describe is typically called "symmetric-key encryption". Commented Aug 23, 2010 at 16:44
  • 1
    I think it's funny that the question puts a TM on Java, but does not capitalize the name as would be required for the trademark to actually apply. Commented Aug 23, 2010 at 16:47
  • sorry oneal, i'm not aware of that :D Commented Aug 23, 2010 at 17:06

5 Answers 5

3

You could use AES.

Sign up to request clarification or add additional context in comments.

1 Comment

@WenZ, try the link I have posted. It contains a sample.
3

You can use any algorithm you want, if you're willing to implement it. If you're asking what algorithms Java provides, the cryptography extension offers (from this list):

  • AES
  • Blowfish
  • DES
  • DESede
  • RC2, RC4, RC5
  • RSA

I believe all those are symmetric (the encryption and decryption key is the same) except for RSA

3 Comments

That link is to the Java 1.4 documentation. I haven't looked around, but you might want to either annotate that or link to a more recent version of that documentation.
@Thomas I'm having trouble finding the newer documentation, but I added a note in the answer
You might want to check it out to verify, but download.oracle.com/javase/6/docs/technotes/guides/security/… appears to be the Java 6 version of what you linked to.
1

Take a look at the Java Cryptography Extension. Here's a simple example.

Comments

1

I would stick to the industry standards - Triple-DES (3DES) or AES, whereby 3DES is slowly being replaced by AES. Libraries and source code for various languages are available, tested and validated.

I would use random generated keys for data encryption, and distribute these keys using asymetric methods (RSA) based on public/private key pairs.

Comments

0

You can use any symmetric key algorithm

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.