【发布时间】:2018-03-27 15:01:59
【问题描述】:
https://github.com/auth0/java-jwt
说明为 JWT 设置算法应该很简单
//RSA
RSAPublicKey publicKey = //Get the key instance
RSAPrivateKey privateKey = //Get the key instance
Algorithm algorithmRS = Algorithm.RSA256(publicKey, privateKey);
问题是我不知道如何在不接触文件系统的情况下创建 RSAPublicKey 和 RSAPrivateKey 实例。
- 它应该是安全的。
- 它不应该在文件系统上创建密钥,因为我打算通过另一种方法存储它。
通常,在我做对之前,我会猜到这种事情,但考虑到它是密码学,我想做正确的事情。
keygen = KeyPairGenerator.getInstance("RSA");
RSAKeyGenParameterSpec spec = new RSAKeyGenParameterSpec(2048, RSAKeyGenParameterSpec.F4); //What does F4 mean vs F0?
keygen.initialize(spec);
KeyPair keypair = keygen.generateKeyPair();
PublicKey pub = keypair.getPublic(); //Wrong type, need RSAPublicKey
PrivateKey priv = keypair.getPrivate(); //Wrong type, need RSAPrivateKey
【问题讨论】:
标签: java cryptography rsa jwt