public byte[] decrypt(byte[] nonce, byte[] ciphertext) { checkLength(nonce, NONCE_BYTES); byte[] ct = prependZeros(BOXZERO_BYTES, ciphertext); byte[] message = new byte[ct.length]; isValid(sodium().crypto_box_curve25519xsalsa20poly1305_open(message, ct, message.length, nonce, publicKey, privateKey), "Decryption failed. Ciphertext failed verification."); return removeZeros(ZERO_BYTES, message); }
public byte[] encrypt(byte[] nonce, byte[] message) { checkLength(nonce, NONCE_BYTES); byte[] msg = prependZeros(ZERO_BYTES, message); byte[] ct = new byte[msg.length]; isValid(sodium().crypto_box_curve25519xsalsa20poly1305(ct, msg, msg.length, nonce, publicKey, privateKey), "Encryption failed"); return removeZeros(BOXZERO_BYTES, ct); }
public byte[] encrypt(byte[] nonce, byte[] message) { checkLength(nonce, NONCE_BYTES); byte[] msg = prependZeros(ZERO_BYTES, message); byte[] ct = new byte[msg.length]; isValid(sodium().crypto_box_curve25519xsalsa20poly1305(ct, msg, msg.length, nonce, publicKey, privateKey), "Encryption failed"); return removeZeros(BOXZERO_BYTES, ct); }
public byte[] decrypt(byte[] nonce, byte[] ciphertext) { checkLength(nonce, NONCE_BYTES); byte[] ct = prependZeros(BOXZERO_BYTES, ciphertext); byte[] message = new byte[ct.length]; isValid(sodium().crypto_box_curve25519xsalsa20poly1305_open(message, ct, message.length, nonce, publicKey, privateKey), "Decryption failed. Ciphertext failed verification."); return removeZeros(ZERO_BYTES, message); }
public byte[] decrypt(byte[] nonce, byte[] ciphertext) { checkLength(nonce, XSALSA20_POLY1305_SECRETBOX_NONCEBYTES); byte[] ct = Util.prependZeros(BOXZERO_BYTES, ciphertext); byte[] message = Util.zeros(ct.length); isValid(sodium().crypto_secretbox_xsalsa20poly1305_open(message, ct, ct.length, nonce, key), "Decryption failed. Ciphertext failed verification"); return removeZeros(ZERO_BYTES, message); } }
public byte[] encrypt(byte[] nonce, byte[] message) { checkLength(nonce, XSALSA20_POLY1305_SECRETBOX_NONCEBYTES); byte[] msg = Util.prependZeros(ZERO_BYTES, message); byte[] ct = Util.zeros(msg.length); isValid(sodium().crypto_secretbox_xsalsa20poly1305(ct, msg, msg.length, nonce, key), "Encryption failed"); return removeZeros(BOXZERO_BYTES, ct); }
public byte[] encrypt(byte[] nonce, byte[] message) { checkLength(nonce, XSALSA20_POLY1305_SECRETBOX_NONCEBYTES); byte[] msg = Util.prependZeros(ZERO_BYTES, message); byte[] ct = Util.zeros(msg.length); isValid(sodium().crypto_secretbox_xsalsa20poly1305(ct, msg, msg.length, nonce, key), "Encryption failed"); return removeZeros(BOXZERO_BYTES, ct); }
public byte[] decrypt(byte[] nonce, byte[] ciphertext) { checkLength(nonce, XSALSA20_POLY1305_SECRETBOX_NONCEBYTES); byte[] ct = Util.prependZeros(BOXZERO_BYTES, ciphertext); byte[] message = Util.zeros(ct.length); isValid(sodium().crypto_secretbox_xsalsa20poly1305_open(message, ct, ct.length, nonce, key), "Decryption failed. Ciphertext failed verification"); return removeZeros(ZERO_BYTES, message); } }