public class Keys extends Object
public static PublicKey getCerPublicKey(InputStream in)
public static PublicKey getCerPublicKey(InputStream in, boolean close)
in
- 流close
- 是否关闭流public static Pair<PublicKey,PrivateKey> getPfxKeys(File file, String password)
public static Pair<PublicKey,PrivateKey> getPfxKeys(String file, String password)
public static Pair<PublicKey,PrivateKey> getPfxKeys(InputStream in, String password)
public static Pair<PublicKey,PrivateKey> getPfxKeys(InputStream in, String password, boolean close)
in
- inpassword
- 密码close
- 是否关闭流public static KeyStore getKeyStore(InputStream in, String password)
in
- inpassword
- passwordpublic static String getPublicKey(PublicKey key)
key
- PublicKeypublic static String getPrivateKey(PrivateKey key)
key
- PrivateKeypublic static String getSecretKey(SecretKey key)
key
- SecretKeypublic static String getKey(InputStream in)
public static int getKeySpecLength(CipherAlgorithm mode)
mode
- modepublic static int getIvSpecLength(CipherAlgorithm mode)
mode
- modepublic static int getGcmSpecLength(CipherAlgorithm mode)
mode
- modepublic static IvParameterSpec getIvSpec(byte[] iv)
public static IvParameterSpec getIvSpec(CipherAlgorithm mode, byte[] iv)
public static IvParameterSpec getIvSpec(byte[] iv, int ivSpecLen)
iv
- 向量ivSpecLen
- 向量长度public static GCMParameterSpec getGcmSpec(byte[] gcm)
public static GCMParameterSpec getGcmSpec(CipherAlgorithm mode, byte[] gcm)
public static GCMParameterSpec getGcmSpec(byte[] gcm, int gcmSpecLen)
gcm
- gcmgcmSpecLen
- 长度public static SecretKey getSecretKey(byte[] key, CipherAlgorithm mode)
key
- StringKeymode
- CipherAlgorithmpublic static SecretKey getSecretKey(String key, CipherAlgorithm mode)
key
- StringKeymode
- CipherAlgorithmpublic static SecretKey generatorKey(String key, CipherAlgorithm mode)
public static SecretKey generatorKey(byte[] key, CipherAlgorithm mode)
public static SecretKey generatorKey(String key, int keySize, CipherAlgorithm mode)
public static SecretKey generatorKey(byte[] key, int keySize, CipherAlgorithm mode)
public static SecretKey generatorKey(byte[] key, int keySize, CipherAlgorithm mode, String algorithm, String provider)
key
- keykeySize
- key 位数
AES 128 192 256 CryptoConst.AES_KEY_LENGTH
DES 8 CryptoConst.DES_KEY_LENGTH
3DES 24 CryptoConst.DES3_KEY_LENGTH
SM4 16 CryptoConst.SM4_KEY_LENGTH
mode
- CipherAlgorithmCopyright © 2024. All rights reserved.