@Test(expectedExceptions = { SymmetricKeyValidationException.class }) public void testCreateEncryptionWithTooShortOfAKey() { Encryptor encryption = new Encryptor(); encryption.setEncryptionKey("Too_short"); }
public void setEncryptionKey(final String encryptionKey) { try { this.secretKeySpec = new SecretKeySpec(encryptionKey.getBytes(CHARSET_NAME), 0, KEY_LENGTH_IN_BYTES, ALGO); } catch (Exception e) { throw new SymmetricKeyValidationException("Encryption key must be string of length: " + KEY_LENGTH_IN_BYTES, e); } }
Encryptor { public void setEncryptionKey(final String encryptionKey) { try { this.secretKeySpec = new SecretKeySpec(encryptionKey.getBytes(CHARSET_NAME), 0, KEY_LENGTH_IN_BYTES, ALGO); } catch (Exception e) { throw new SymmetricKeyValidationException("Encryption key must be string of length: " + KEY_LENGTH_IN_BYTES, e); } } }
Encryptor { public void setEncryptionKey(final String encryptionKey) { try { this.secretKeySpec = new SecretKeySpec(encryptionKey.getBytes(CHARSET_NAME), 0, KEY_LENGTH_IN_BYTES, ALGO); } catch (Exception e) { throw new SymmetricKeyValidationException("Encryption key must be string of length: " + KEY_LENGTH_IN_BYTES, e); } }  }
Encryptor { public void setEncryptionKey(final String encryptionKey) { try { this.secretKeySpec = new SecretKeySpec(encryptionKey.getBytes(CHARSET_NAME), 0, KEY_LENGTH_IN_BYTES, ALGO); } catch (Exception e) { throw new SymmetricKeyValidationException("Encryption key must be string of length: " + KEY_LENGTH_IN_BYTES, e); } }  String encrypt(final String value); String decrypt(final String encrypted); void setEncryptionKey(final String encryptionKey); }
Encryptor { public void setEncryptionKey(final String encryptionKey) { try { this.secretKeySpec = new SecretKeySpec(encryptionKey.getBytes(CHARSET_NAME), 0, KEY_LENGTH_IN_BYTES, ALGO); } catch (Exception e) { throw new SymmetricKeyValidationException("Encryption key must be string of length: " + KEY_LENGTH_IN_BYTES, e); } }  String encrypt(final String value); String decrypt(final String encrypted); void setEncryptionKey(final String encryptionKey);  }