Foxtable(狐表)用户栏目专家坐堂 → PEM格式密钥怎么处理啊


  共有90人关注过本帖树形打印复制链接

主题:PEM格式密钥怎么处理啊

帅哥哟,离线,有人找我吗?
aidimeng
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:810 积分:7769 威望:0 精华:0 注册:2015/9/14 14:26:00
PEM格式密钥怎么处理啊  发帖心情 Post By:2025/1/1 13:15:00 [只看该作者]

Dim rsa = New System.Security.Cryptography.RSACryptoServiceProvider()
Dim ByteConverter As New UnicodeEncoding()
'Dim dataToEncrypt As Byte() = ByteConverter.GetBytes("ww我wData to Encrypt")
'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2KbR4DybAGoFvZleBqdHtnX03Bf2CvzsdCZf8/t5mNsISlKdkRVeqc7JimvHny7sICCMmmWZYu33ZzJkDXSKB8JDM2hugwB3Von8aWiMYxKjq43Hn0vfv7M+70WjX0TNGoyMFLKSN9rsqMtIAuD+Ipv6Aovlw+1PjGMPZ2XtUbB010/JEP7d1NjyKxKhFryKzBOc4FhNfis6EJIpsFnA1LKIvg/Mw0BY/f9u6lafCPR+OO4Ula4PShV1nD3TfNYlWNCocZtxVlVfqR78c0Tpe2+jkG8BEtylzff2olEf0z+YwxqyOdHxutMlEnoYa16kkqpc+IRdeaGhcKSwpKvk4QIDAQAB
Dim dataToEncrypt As String = "784e9291-e51f-4b12-900e-3736b0d401f3"
Dim pck As String = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2KbR4DybAGoFvZleBqdHtnX03Bf2CvzsdCZf8/t5mNsISlKdkRVeqc7JimvHny7sICCMmmWZYu33ZzJkDXSKB8JDM2hugwB3Von8aWiMYxKjq43Hn0vfv7M+70WjX0TNGoyMFLKSN9rsqMtIAuD+Ipv6Aovlw+1PjGMPZ2XtUbB010/JEP7d1NjyKxKhFryKzBOc4FhNfis6EJIpsFnA1LKIvg/Mw0BY/f9u6lafCPR+OO4Ula4PShV1nD3TfNYlWNCocZtxVlVfqR78c0Tpe2+jkG8BEtylzff2olEf0z+YwxqyOdHxutMlEnoYa16kkqpc+IRdeaGhcKSwpKvk4QIDAQAB"
Dim encryptedData() As Byte
Dim decryptedData() As Byte
Dim gs As String = "<RSAKeyValue><Modulus>" & pck & "</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"'rsa.ToXmlString(False) '生成 公匙
Output.Show(gs)
Dim ss As String = rsa.ToXmlString(True) ''生成 私匙
rsa.FromXmlString(gs) '公匙
encryptedData = RSA.Encrypt(encoding.UTF8.GetBytes(DataToEncrypt), False)
'output.show("加密后:" & ByteConverter.GetString(encryptedData))
output.show("加密后:" & convert.ToBase64String(encryptedData))
'rsa.FromXmlString(ss)
'decryptedData = RSA.Decrypt(encryptedData, False)
'output.show("解密后: " & encoding.UTF8.Getstring(decryptedData))

遇到的问题;对方给了指定的密钥 pck ,如果不构造成 <RSAKeyValue><Modulus>" & pck & "</ 这样 程序报错,我这样构造下,可以加密,但得到的结果和在线加密得到的结果不一样
图片点击可在新窗口打开查看
[此贴子已经被作者于2025/1/1 17:18:37编辑过]

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111585 积分:568037 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2025/1/2 8:44:00 [只看该作者]

接口开发文档发过来看看

 回到顶部