Add examples

This commit is contained in:
2024-06-06 01:51:04 +02:00
parent 44094a31f1
commit c05f0536e2
5 changed files with 78 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import {expect} from 'bun:test'
import {PrivateWrap} from '../index'
const key_wraps = await PrivateWrap.gen_keypair()
const key_wrapped = await PrivateWrap.gen_keypair()
const cipher = await PrivateWrap.encrypt(key_wrapped.privateKey, key_wraps.publicKey)
const box = await cipher.toString()
const unbox = await PrivateWrap.fromString(box)
const plain = await unbox.decrypt(key_wraps.privateKey)
expect(plain).toEqual(key_wrapped.privateKey)
console.log("ecdh-wraps-ecdh OK")