Add byte serialization
This commit is contained in:
+15
-1
@@ -39,7 +39,7 @@ test("Encryption doesn't work with different context", async () => {
|
||||
expect(unboxed).toBeNull()
|
||||
})
|
||||
|
||||
test('serialization', async () => {
|
||||
test('String serialization', async () => {
|
||||
const box = await PwdBox.encrypt(message, k1)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
@@ -53,3 +53,17 @@ test('serialization', async () => {
|
||||
expect(unboxed).not.toBeNull()
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
test('Byte serialization', async () => {
|
||||
const box = await PwdBox.encrypt(message, k1)
|
||||
expect(box).not.toBeNull()
|
||||
|
||||
const ser = box!.toBytes()
|
||||
const de = PwdBox.fromBytes(ser)
|
||||
|
||||
expect(de).not.toBeNull()
|
||||
expect(de).toEqual(box)
|
||||
|
||||
const unboxed = await de!.decrypt(k1)
|
||||
expect(unboxed).not.toBeNull()
|
||||
expect(unboxed).toEqual(message)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user