Improve code quality and add decrypt status return value
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { referenceTests } from './resources/reference-tests'
|
||||
import { cryptoAeadDecrypt, cryptoAeadEncrypt } from '../src/romulus-m'
|
||||
import { cryptoAeadDecrypt, cryptoAeadEncrypt, DecryptResult } from '../src/romulus-m'
|
||||
|
||||
function parseHexString (string: string): number[] {
|
||||
const ret = []
|
||||
@@ -24,6 +24,9 @@ test.each(referenceTests)('Perform decryption using reference test %#.', (key, n
|
||||
const result = cryptoAeadDecrypt(parseHexString(ciphertext), parseHexString(associatedData), parseHexString(nonce), parseHexString(key))
|
||||
|
||||
// Then
|
||||
const expectedResult = parseHexString(plaintext)
|
||||
const expectedResult: DecryptResult = {
|
||||
success: true,
|
||||
plaintext: parseHexString(plaintext)
|
||||
}
|
||||
expect(result).toMatchObject(expectedResult)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user