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, SecretBox} from '../index'
const k_wraps = await PrivateWrap.gen_keypair()
const k_wrapped = await SecretBox.gen_key()
const cipher = await PrivateWrap.encrypt(k_wrapped, k_wraps.publicKey)
const box = await cipher.toString()
const unbox = await PrivateWrap.fromString(box)
const plain = await unbox.decrypt(k_wraps.privateKey) as CryptoKey
expect(plain).toEqual(k_wrapped)
console.log("ecdh-wraps-key OK")