NetBox 2.7 使用手册

RSA 对象

非对称加密算法 RSA 加密解密对象

语法

Set rsa = CreateObject("NetBox.RSA")
 

属性

IsPrivateKey 查询当前的 RSA 对象所包含的密钥是是否是私钥
Key 读取当前对象中包含的密钥,根据不同对象返回公钥或私钥
KeySize 查询当前对象的密钥尺寸
Padding 查询和设定当前填充模式,确省为 1
PrivateKey 读取或设定当前对象中包含的私钥
PublicKey 读取或设定当前对象中包含的公钥

方法

Decrypt 使用对象内的公钥或者私钥解密数据
Encrypt 使用对象内的公钥或者私钥加密数据
GenerateKey 创建一个密钥

注释

下面的例子创建一个 rsa 对象,创建一个私钥,加密一段数据。然后创建另外一个 rsa 对象,使用第一个对象的公钥对刚才加密的结果解密,并以 16 进制输出数据:

Set rand = CreateObject("netbox.random")
Set rsa = CreateObject("netbox.rsa")
Set rsa1 = CreateObject("netbox.rsa")
rsa.GenerateKey
a = rand(50)
Shell.Console.WriteLine NetBox.Encoding.base64Encode(a)
b = rsa.Encrypt(a)
rsa1.PublicKey = rsa.PublicKey
c = rsa1.Decrypt(b)
Shell.Console.WriteLine NetBox.Encoding.base64Encode(a)

版权所有: 2003- 网络盒子