今天,我发现有两种带有PEM格式头的公钥格式,例如
X.509 SubjectPublicKeyInfo** (PEM header: BEGIN PUBLIC KEY)
其对应于短标头形式;
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzsQ7MkLsc1lJ8S2WtItN
cfj7pbdB6PVcRHEEjbie97Rqthkr6h2WE5rVj0BZNwFjs4NIUYws2KeQjexZ8NEY
qpcP9iPMjdNgLpU8uL03QMti+y+y0IU4493KxKxjprjtu6
我想用RSA加密和解密文件。加密效果很好。但我解密的时候会出错。
错误是键不存在。
以下是错误:
public byte[] RSA_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes, RSAParameters RSAKeyInfo)
{
//initialze the byte arrays to the public key information.
byte[] PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,
我正在尝试使用Ionic中的SubtleCrypto Web来使用公钥加密数据。我将导入PEM格式的密钥,然后将其传递到window.crypto.subtle.importKey,然后将结果使用到window.crypto.subtle.encrypt中。
看起来window.crypto.subtle.importKey有一个问题--当我试图导入密钥时,我得到了一个Uncaught (in promise): DataError。
我目前正在使用以下方法导入密钥:
//Get the public key in CryptoKey format
let importedPublicKey
我也试过用腻子。我在那里选择了这个pem键,得到了以下内容:
Unable to use key file "key.pem" (not a private key).
我读到,可以将pem转换为pub键。我就是这样做的:
将pem键转换为ssh-rsa格式
如何将PEM密钥转换为RSA密钥对?
但是当我试图连接时,我也遇到了同样的错误。
使用C,我可以使用PEM_write_RSAPublicKey()生成RSA公钥并将其写入到PEM文件中。
但我希望将多个公钥写入单个文件(如known_hosts或authorized_hosts),而不是拥有一个separate PEM file for each。
我知道怎么encode/decode base64
但是我如何获得public key from the RSA structure (which I can base64 encode) and later read the same key from file and put it back into the RSA st