I am trying to understand some legacy code where one of the parameter to Cipher.init
is 2. What does 2 signify here?
try
{
if (key == null)
{
key = SecretKeyFactory.getInstance("DESede").generateSecret(new DESedeKeySpec(keyBytes));
}
Cipher cipher = Cipher.getInstance("DESede");
cipher.init(2, key);
}
What does 2 signify here?
That's opmode
. From Cipher
class Javadocs:
void init(int opmode, Key key)
I believe 2 is DECRYPT_MODE
. See the Constant Field Values at the bottom of the page.