How to handle multiple Ciphers
I'm thinking about creating several Ciphers and putting them in a
collection. Mainly for optimization when creating keys and initializing
the Cipher object. They will be used a lot.
Map<Integer, Cipher> encrytors = new HashMap<Integer, Cipher>();
Key key = new SecretKeySpec(secret, KEY_ALGORITHM);
Cipher encrypter = Cipher.getInstance(CIPHER_ALOGORITHM);
encrypter.init(Cipher.ENCRYPT_MODE, key);
encrytors.put(1, encrypter);
Key key2 = new SecretKeySpec(secret2, KEY_ALGORITHM);
Cipher encrypter2 = Cipher.getInstance(CIPHER_ALOGORITHM);
encrypter2.init(Cipher.ENCRYPT_MODE, key2);
encrytors.put(2, encrypter);
Good/bad? How does people handle several different keys and ciphers?
No comments:
Post a Comment