需要一个Delphi组件/库,允许我使用RSA加密/解密某些文本
发布时间:2020-12-15 09:48:08 所属栏目:大数据 来源:网络整理
导读:我需要一个组件或库(尽可能简单,没有DLL会很好)加密文本,使用OpenSSL生成的公钥解密另一个文本. 我以为我会使用LockBox(新版本,v3),但据其他用户说,它不如旧版本好,更重要的是,不能使用其他库中的密钥. (见OpenSSL’s PEM file and Lockbox3 interoperabilit
我需要一个组件或库(尽可能简单,没有DLL会很好)加密文本,使用OpenSSL生成的公钥解密另一个文本.
我以为我会使用LockBox(新版本,v3),但据其他用户说,它不如旧版本好,更重要的是,不能使用其他库中的密钥. (见OpenSSL’s PEM file and Lockbox3 interoperability) 我正在使用Delphi 7.有什么建议吗? 解决方法
我们在Delphi 2010中使用Lockbox 2,效果很好.我想它也适用于Delphi 7.这是一个代码示例:
unit LBRSA; interface uses LbCipher,LbRSA,LbString,LbUtils; function DecryptRSA(const CipherText: String): String; overload; overload; function DecryptRSA(const CipherText,Exponent,Modulus: String): String; overload; implemention function EncryptRSA(const ClearText,Modulus: String): String; var RSA: TLbRSA; begin RSA := TLbRSA.Create(nil); try RSA.PublicKey.ExponentAsString := Exponent; RSA.PublicKey.ModulusAsString := Modulus; Result := RSA.EncryptStringW(ClearText); finally FreeAndNil(RSA); end; end; function DecryptRSA(const CipherText,Modulus: String): String; var RSA: TLbRSA; begin RSA := TLbRSA.Create(nil); try RSA.PrivateKey.ExponentAsString := Exponent; RSA.PrivateKey.ModulusAsString := Modulus; Result := RSA.DecryptStringW(CipherText); finally FreeAndNil(RSA); end; end; end. Lockbox包含一个演示应用程序,可让您生成公钥和私钥. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |