oso*_*dyj 1 java constructor type-conversion
我需要生成一个具有私钥值的密钥,并且可以将其存储在密钥库中。我需要使用该方法setEntry
代码附件:
privateKey = keypair.getPrivate();
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(password);
javax.crypto.SecretKey mySecretKey= null;
KeyStore.SecretKeyEntry skEntry= new KeyStore.SecretKeyEntry(mySecretKey);
ks.setEntry("secretKeyAlias", skEntry, protParam);
Run Code Online (Sandbox Code Playgroud)
相信这是不可能的。
从逻辑上讲,SecretKey代表对称密钥,而PrivateKey是公钥和私钥对的一部分。
此外,就对象建模而言,它们都是接口。因此,一个不能“转换”为另一个(除非存在一个实现这两个接口但没有意义的类)。
| 归档时间: |
|
| 查看次数: |
3975 次 |
| 最近记录: |