Add public API

This commit is contained in:
Jack Hadrill
2022-01-31 00:02:51 +00:00
parent ba4c9399a9
commit d77b54a2f8
6 changed files with 55 additions and 2 deletions

6
src/decrypt.ts Normal file
View File

@@ -0,0 +1,6 @@
import { cryptoAeadDecrypt } from './romulus-m'
export function decrypt (ciphertext: Buffer, associatedData: Buffer, nonce: Buffer, key: Buffer): Buffer {
const plaintext = cryptoAeadDecrypt(Array.from(ciphertext), Array.from(associatedData), Array.from(nonce), Array.from(key))
return Buffer.from(plaintext)
}

6
src/encrypt.ts Normal file
View File

@@ -0,0 +1,6 @@
import { cryptoAeadEncrypt } from './romulus-m'
export function encrypt (message: Buffer, associatedData: Buffer, nonce: Buffer, key: Buffer): Buffer {
const ciphertext = cryptoAeadEncrypt(Array.from(message), Array.from(associatedData), Array.from(nonce), Array.from(key))
return Buffer.from(ciphertext)
}

View File

@@ -1 +1,2 @@
console.log('Hello, World')
export { encrypt } from './encrypt'
export { decrypt } from './decrypt'