英文:
Smallest RSA Key File Size possible
问题
I'm here to provide translations for the code-related content you've provided. Here's the translated code portion:
我正在尝试获得最小的RSA密钥对文件大小,以便在QR码上进行额外加密保存。我希望大小尽可能接近默认的2048位,但不幸的是,我只能导出带有附加的CRT数据,这仅用于加快计算速度。对我来说,大小比速度更重要。
我正在使用BouncyCastle并成功创建了一个`AsymmetricCipherKeyPair`。我成功获取了“过大”的私钥,方法如下:
```java
AsymmetricKeyParameter rsaPri = res.Private;
PrivateKeyInfo p = PrivateKeyInfoFactory.CreatePrivateKeyInfo(rsaPri);
byte[] piby = p.Attributes.GetEncoded();
其中res
等于提到的AsymmetricCipherKeyPair
。
如何仅获取e、N和d、N从密钥对中?
此外,如何再次导入它?
我已经进行了多个小时的研究,但我很难理解它。
任何帮助都将不胜感激
Please note that the translation is provided for the code portion, as you requested. If you have any further code-related questions or need assistance with a specific part of the code, please feel free to ask.
<details>
<summary>英文:</summary>
I'm trying to get the smallest rsa key pair file size possible to save with extra encryption on a QR-Code. I'd like the size to be as close as possible to the default 2048 bits, but unfortunatly I've only managed to export it with the additional CRT-Data, which is only usefull for faster calculation. To me size is more important than speed.
I'm using BouncyCastle and managed to create an `AsymmetricCipherKeyPair`. The "oversized" Private Key i managed to get by using:
AsymmetricKeyParameter rsaPri = res.Private;
PrivateKeyInfo p = PrivateKeyInfoFactory.CreatePrivateKeyInfo(rsaPri);
byte[] piby = p.Attributes.GetEncoded();
Where res is equal to the mentioned `AsymmetricCipherKeyPair`
How can I achieve only getting e,N and d,N from Keypair?
And further more, how can I import it again?
I've done multiple hours of research but I'm strugging to wrap my head around it.
Any assistance is apprechiaded :)
</details>
# 答案1
**得分**: 1
"如预期,有一种简单的方法可以做到这一点:正如progman所述,可以轻松地将`AsymmetricKeyParameter`解析为`RsaKeyParameters`并提取我正在寻找的值。"
<details>
<summary>英文:</summary>
as expected there is an easy way of doing this: as progman stated, one can easily parse the `AsymmetricKeyParameter` as `RsaKeyParameters` and extract the values I was looking for.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论