Add examples
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user