21 lines
875 B
TypeScript
21 lines
875 B
TypeScript
import { encrypt } from '../src/encrypt'
|
|
|
|
test('Test buffers are supported by encrypt function.', () => {
|
|
// Given
|
|
const message = Buffer.from('Hello, World! This is a test message.')
|
|
const associatedData = Buffer.from('Some associated data.')
|
|
const nonce = Buffer.from('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
|
|
const key = Buffer.from('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')
|
|
|
|
// When
|
|
const result = encrypt(message, associatedData, nonce, key)
|
|
|
|
// Then
|
|
const expectedResult = Buffer.from([
|
|
225, 53, 3, 212, 22, 112, 246, 194, 61, 171, 230, 187, 157, 102, 32, 76, 62, 65,
|
|
25, 202, 255, 201, 206, 49, 60, 58, 82, 216, 72, 116, 106, 129, 162, 142, 69, 40,
|
|
167, 88, 94, 195, 174, 217, 242, 149, 224, 125, 196, 237, 172, 165, 116, 119, 128
|
|
])
|
|
expect(result).toMatchObject(expectedResult)
|
|
})
|