b6bb3098bc
many other updates
11 lines
379 B
JavaScript
11 lines
379 B
JavaScript
import crypto from "apigo.cloud/git/apigo/plugins/crypto"
|
|
|
|
let [priKey, pubKey] = crypto.sm2.genKey()
|
|
let s1 = crypto.sm2.sign('hello 123', priKey)
|
|
if(!crypto.sm2.verify('hello 123', s1, pubKey)) throw new Error('')
|
|
let s2 = crypto.sm2.encrypt('hello 123', pubKey)
|
|
let s3 = crypto.sm2.decrypt(s2, priKey)
|
|
if( s3 !== 'hello 123') throw new Error('sm2 decrypt error')
|
|
|
|
return true
|