gpt4 book ai didi

Android 创建 RSA 1024 .NET 兼容 key

转载 作者:行者123 更新时间:2023-11-30 04:50:28 24 4
gpt4 key购买 nike

我正在开发一个 Android 应用程序,我需要生成一些 RSA 私钥和公钥以用于与 Web 服务的安全通信。为此,我需要具有 .NET 兼容形式的公钥。喜欢:

<RSAKeyValue><Modulus>{0}</Modulus><Exponent>{1}</Exponent></RSAKeyValue>

到目前为止,我设法做到了这一点:

  keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(1024);
keypair = keyGen.genKeyPair();
privateKey = keypair.getPrivate();
publicKey = keypair.getPublic();

// Get the bytes of the public and private keys
byte[] privateKeyBytes = privateKey.getEncoded();
byte[] publicKeyBytes = publicKey.getEncoded();

我不知道如何继续。你能提供一些帮助吗?

最佳答案

对于其他感兴趣的人,可以在此处找到非常好的教程

http://www.codeproject.com/KB/security/porting_java_public_key.aspx?msg=3407475

如果您需要 Base64 编码/解码,因为它不包含在 Android 中(至少在 API 4 中),您可以使用这里的类:iharder.sourceforge.net/current/java/base64/

关于Android 创建 RSA 1024 .NET 兼容 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3629036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com