添加生成密钥和公钥的例子
This commit is contained in:
parent
a201651785
commit
e62ba6a9d7
|
|
@ -19,6 +19,24 @@ local id = snow:generateUniqueId()-- 生成ID
|
|||
|
||||
--max =a and b or c--a?b:c
|
||||
|
||||
local openssl = require("openssl")
|
||||
|
||||
-- 生成RSA密钥对
|
||||
local key = openssl.pkey.new {
|
||||
algorithm = "RSA",
|
||||
rsa = {
|
||||
bits = 2048 -- 密钥长度
|
||||
}
|
||||
}
|
||||
|
||||
-- 导出私钥和公钥
|
||||
local private_key_pem = key:pem() -- 获取私钥的PEM格式
|
||||
local public_key_pem = key:public_key():pem() -- 获取公钥的PEM格式
|
||||
|
||||
-- 打印密钥
|
||||
ngx.say("Private Key:"..private_key_pem)
|
||||
ngx.say("\nPublic Key:"..public_key_pem)
|
||||
|
||||
--[[
|
||||
local radix = require("resty.radixtree")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user