-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
19 lines (16 loc) · 703 Bytes
/
Copy pathtest.ts
File metadata and controls
19 lines (16 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as RSA from './rsa'
(async () => {
const { privateKey, publicKey } = await RSA.generateKeyPair()
console.log(`\nprivateKey: ${privateKey}`)
console.log(`\npublicKey: ${publicKey}`)
const encrypted = RSA.encrypt('test', publicKey)
const decrypted = RSA.decrypt(encrypted, privateKey)
console.log(`\nencrypted: ${encrypted}`)
console.log(`\ndecrypted: ${decrypted}`)
const signed = RSA.sign('my public sign', privateKey)
const extracted = RSA.extract(signed)
const verified = RSA.verify(signed, 'my public sign', publicKey)
console.log(`\nsigned: ${signed}`)
console.log(`\nextracted:`, extracted)
console.log(`\nverified: ${verified}`)
})()