Java using AES 256 and 128 Symmetric-key encryption -


i new in cipher technology. found code symmetric encryption.

byte[] key = //... secret sequence of bytes byte[] datatosend = ... cipher c = cipher.getinstance("aes"); secretkeyspec k = new secretkeyspec(key, "aes"); c.init(cipher.encrypt_mode, k); byte[] encrypteddata = c.dofinal(datatosend); 

its working. here can use own password. , thats needed. dont know how 128 or 256 symmetric enctryption. how can use 128 , 256 key code ?

whether aes uses 128 or 256 bit mode depends on size of key, must 128 or 256 bits long. typically don't use password key, because passwords have exact length need. instead, derive encryption key password using key derivation function.

very simple example: take md5 of password 128-bit key. if want 256-bit key, can use sha-256 256-bit hash of password. key-derivation functions run hashing several hundreds time , use salt well. check out http://en.wikipedia.org/wiki/key_derivation_function details.

also note: run encryption stronger 128-bit need download , install 'java cryptography extension (jce) unlimited strength jurisdiction policy files 6' http://www.oracle.com/technetwork/java/javase/downloads/index.html.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -