use of com.sparrowwallet.drongo.crypto.ECIESKeyCrypter in project sparrow by sparrowwallet.
the class ECIESOutputStream method close.
@Override
public void close() throws IOException {
super.close();
byte[] unencrypted = ((ByteArrayOutputStream) out).toByteArray();
ECIESKeyCrypter keyCrypter = new ECIESKeyCrypter();
EncryptedData encryptedData = keyCrypter.encrypt(unencrypted, encryptionMagic, encryptionKey);
ByteStreams.copy(new ByteArrayInputStream(encryptedData.getEncryptedBytes()), encryptedStream);
encryptedStream.flush();
encryptedStream.close();
}
use of com.sparrowwallet.drongo.crypto.ECIESKeyCrypter in project sparrow by sparrowwallet.
the class ECIESInputStream method ensureDecrypted.
private synchronized void ensureDecrypted() throws IOException {
if (!decrypted) {
byte[] encryptedBytes = ByteStreams.toByteArray(in);
in.close();
ECIESKeyCrypter keyCrypter = new ECIESKeyCrypter();
byte[] decryptedBytes = keyCrypter.decrypt(new EncryptedData(encryptionMagic, encryptedBytes, null, null), decryptionKey);
in = new ByteArrayInputStream(decryptedBytes);
decrypted = true;
}
}
Aggregations