18 lines
624 B
TypeScript
18 lines
624 B
TypeScript
import { decrypt } from '../src/decrypt'
|
|
import { encrypt } from '../src/encrypt'
|
|
|
|
test('Test nonce generation by public encrypt function.', () => {
|
|
// Given
|
|
const message = Buffer.from('Hello, World! This is a test message.')
|
|
const associatedData = Buffer.from('Some associated data.')
|
|
const key = Buffer.from('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
|
|
|
|
// When
|
|
const ciphertext = encrypt(message, associatedData, key)
|
|
const plaintext = decrypt(ciphertext, associatedData, key)
|
|
|
|
// Then
|
|
expect(plaintext.success).toBe(true)
|
|
expect(plaintext.plaintext).toMatchObject(message)
|
|
})
|