Above is a short symmetric encrypt/decrypt code. If I have to encrypt the string in one machine and decrypt it on another machine, and want to follow this code snippet, I certainly don't want to use
byte initvector = ci.getIV();
because I don't want to pass this "initvector" to the other machine. How can I let two machines use a agreed key or "password" to accomplish the encrypt and decrypt ? any snippet to share ? This snippet isn't a good example I guess because it generates a key on one machine, but how do I pass to another ?
I am new to JCE world, but my guess is two machines should use a common "password" and algorithm to retrieve the key (or maybe the password itself can be the key), and then one side can encrypt using this key, and the other side can decrypt using the same key.. Any snippet matching this logic ? maybe I am totally wrong.