3

【踩坑】Dart 的 RSA 加解密报错

 1 year ago
source link: https://loli.fj.cn/2023/08/03/Dart%E7%9A%84RSA%E5%8A%A0%E8%A7%A3%E5%AF%86%E6%8A%A5%E9%94%99/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【踩坑】Dart 的 RSA 加解密报错

2023-08-03 2023-08-06

Dart 的 RSA 加解密报错:Unhandled Exception: type 'ASN1Sequence' is not a subtype of type 'ASN1Integer' in type cast

  • Dart 中的 RSA 密钥中没有 RSA 关键字,而 Go 语言生成的 RSA 密钥中包含 RSA 关键字
  • RSA 关键字从 RSA 密钥中去除

转换公钥中的 RSA 关键字

  • -----BEGIN RSA PUBLIC KEY----- 转换为 -----BEGIN PUBLIC KEY-----
  • -----END RSA PUBLIC KEY----- 转换为 -----END PUBLIC KEY-----
rsaPublicKey = rsaPublicKey.replaceAll("-----BEGIN RSA PUBLIC KEY-----", "-----BEGIN PUBLIC KEY-----");
rsaPublicKey = rsaPublicKey.replaceAll("-----END RSA PUBLIC KEY-----", "-----END PUBLIC KEY-----");

转换私钥中的 RSA 关键字

  • -----BEGIN RSA PRIVATE KEY----- 转换为 -----BEGIN PRIVATE KEY-----
  • -----END RSA PRIVATE KEY----- 转换为 -----END PRIVATE KEY-----

CSDN—— 立青_
Github——psycura


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK