@Test public void etaEncrypt() throws Exception { SymmetricKey k = new SymmetricKey(); byte[] plainText = "Hello, world!".getBytes(); byte[] cipherText = k.etaEncrypt(plainText); assertEquals(16 + 32 + plainText.length, cipherText.length); byte[] decryptedText = k.etaDecrypt(cipherText); assertArrayEquals(plainText, decryptedText); exception.expect(SymmetricKey.AuthenticationFailed.class); cipherText[19] += 1; k.etaDecrypt(cipherText); }
public byte[] etaEncrypt(byte[] data) throws EncryptionError { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final EtaEncryptingStream s = etaEncryptStream(bos); s.write(data); s.end(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected IOError", e); } }
SymmetricKey extends AbstractKey implements Serializable, Hashable { public byte[] etaEncrypt(byte[] data) throws EncryptionError { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final EtaEncryptingStream s = etaEncryptStream(bos); s.write(data); s.end(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected IOError", e); } } }
SymmetricKey extends AbstractKey implements Serializable, Hashable { public byte[] etaEncrypt(byte[] data) throws EncryptionError { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final EtaEncryptingStream s = etaEncryptStream(bos); s.write(data); s.end(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected IOError", e); } } SymmetricKey();  SymmetricKey(byte[] key);  SymmetricKey(byte[] key, KeyInfo keyInfo); }
SymmetricKey extends AbstractKey implements Serializable, Hashable { public byte[] etaEncrypt(byte[] data) throws EncryptionError { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final EtaEncryptingStream s = etaEncryptStream(bos); s.write(data); s.end(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected IOError", e); } } SymmetricKey();  SymmetricKey(byte[] key);  SymmetricKey(byte[] key, KeyInfo keyInfo); static SymmetricKey fromPassword(String password, int rounds); static SymmetricKey fromPassword(String password, int rounds, byte[] salt); void setKey(byte[] key); byte[] getKey(); int getBitStrength(); int getSize(); @Override Map<String, Object> toHash(); @Override void updateFromHash(Map<String, Object> hash); byte[] encrypt(byte[] plaintext); byte[] decrypt(byte[] ciphertext); OutputStream encryptStream(OutputStream outputStream); InputStream decryptStream(InputStream inputStream); EtaEncryptingStream etaEncryptStream(OutputStream out); EtaDecryptingStream etaDecryptStream(InputStream in); byte[] etaEncrypt(byte[] data); byte[] etaSign(byte[] data); byte[] etaDecrypt(byte[] data); static byte[] xor(byte[] src, int value); @Override byte[] pack(); @Override boolean equals(Object obj); @Override int hashCode(); }
SymmetricKey extends AbstractKey implements Serializable, Hashable { public byte[] etaEncrypt(byte[] data) throws EncryptionError { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { final EtaEncryptingStream s = etaEncryptStream(bos); s.write(data); s.end(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException("unexpected IOError", e); } } SymmetricKey();  SymmetricKey(byte[] key);  SymmetricKey(byte[] key, KeyInfo keyInfo); static SymmetricKey fromPassword(String password, int rounds); static SymmetricKey fromPassword(String password, int rounds, byte[] salt); void setKey(byte[] key); byte[] getKey(); int getBitStrength(); int getSize(); @Override Map<String, Object> toHash(); @Override void updateFromHash(Map<String, Object> hash); byte[] encrypt(byte[] plaintext); byte[] decrypt(byte[] ciphertext); OutputStream encryptStream(OutputStream outputStream); InputStream decryptStream(InputStream inputStream); EtaEncryptingStream etaEncryptStream(OutputStream out); EtaDecryptingStream etaDecryptStream(InputStream in); byte[] etaEncrypt(byte[] data); byte[] etaSign(byte[] data); byte[] etaDecrypt(byte[] data); static byte[] xor(byte[] src, int value); @Override byte[] pack(); @Override boolean equals(Object obj); @Override int hashCode();  }