public class AlgorithmUtil extends Object
| Constructor and Description |
|---|
AlgorithmUtil() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decrypt(Cipher cipher,
Key key,
AlgorithmParameterSpec algorithmParameterSpec,
byte[] content)
decrypt data
|
static byte[] |
decrypt(Cipher cipher,
Key key,
byte[] content)
decrypt data
|
static byte[] |
encrypt(Cipher cipher,
Key key,
AlgorithmParameterSpec algorithmParameterSpec,
byte[] content)
encrypt data
|
static byte[] |
encrypt(Cipher cipher,
Key key,
byte[] content)
encrypt data
|
static AlgorithmParameterGenerator |
generateAlgorithmParameterGenerator(String algorithm) |
static AlgorithmParameters |
generateAlgorithmParameters(String algorithm,
int length) |
static AlgorithmParameterSpec |
generateAlgorithmParameterSpec(String algorithm,
int length,
Class<? extends AlgorithmParameterSpec> type) |
static KeyFactory |
generateKeyFactory(String algorithm) |
static KeyGenerator |
generateKeyGenerator(String algorithm)
generate key generator
|
static KeyGenerator |
generateKeyGenerator(String algorithm,
int length)
generate key generator
|
static KeyGenerator |
generateKeyGenerator(String algorithm,
int length,
String provider)
generate key generator
|
static KeyPair |
generateKeyPair(String algorithm,
AlgorithmParameterSpec params) |
static KeyPair |
generateKeyPair(String algorithm,
AlgorithmParameterSpec params,
SecureRandom secureRandom) |
static KeyPair |
generateKeyPair(String algorithm,
int length) |
static KeyPairGenerator |
generateKeyPairGenerator(String algorithm,
AlgorithmParameterSpec params) |
static KeyPairGenerator |
generateKeyPairGenerator(String algorithm,
AlgorithmParameterSpec params,
SecureRandom secureRandom) |
static KeyPairGenerator |
generateKeyPairGenerator(String algorithm,
int length) |
static Mac |
generateMac(String algorithm,
Key secretKey) |
static Signature |
generateReceiverSignature(String algorithm,
PublicKey publicKey) |
static Key |
generateSecretKey(String algorithm)
secret key generator
|
static Key |
generateSecretKey(String algorithm,
int length)
secret key generator
|
static Key |
generateSecretKey(String algorithm,
int length,
String provider)
secret key generator
|
static byte[] |
generateSecretKeyEncodedBytes(String algorithm)
generate secret key encoded bytes
|
static byte[] |
generateSecretKeyEncodedBytes(String algorithm,
int length)
generate secret key encoded bytes
|
static byte[] |
generateSecretKeyEncodedBytes(String algorithm,
int length,
String provider)
generate secret key encoded bytes
|
static byte[] |
generateSeedBytes(int length)
生成随机种子
|
static Signature |
generateSenderSignature(String algorithm,
PrivateKey privateKey) |
static byte[] |
signData(String algorithm,
PrivateKey privateKey,
byte[] content) |
static boolean |
verifySign(String algorithm,
PublicKey publicKey,
byte[] content,
byte[] sign) |
public static KeyGenerator generateKeyGenerator(String algorithm, int length, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度provider - 算法提供商NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static KeyGenerator generateKeyGenerator(String algorithm, int length) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static KeyGenerator generateKeyGenerator(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static Key generateSecretKey(String algorithm, int length, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度provider - 算法提供商NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static Key generateSecretKey(String algorithm, int length) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static Key generateSecretKey(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static KeyPairGenerator generateKeyPairGenerator(String algorithm, int length) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static KeyPairGenerator generateKeyPairGenerator(String algorithm, AlgorithmParameterSpec params, SecureRandom secureRandom) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static KeyPairGenerator generateKeyPairGenerator(String algorithm, AlgorithmParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static KeyPair generateKeyPair(String algorithm, int length) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static KeyPair generateKeyPair(String algorithm, AlgorithmParameterSpec params, SecureRandom secureRandom) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static KeyPair generateKeyPair(String algorithm, AlgorithmParameterSpec params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
public static KeyFactory generateKeyFactory(String algorithm) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static byte[] generateSecretKeyEncodedBytes(String algorithm, int length, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度provider - 算法提供商NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static byte[] generateSecretKeyEncodedBytes(String algorithm, int length) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法length - 密钥长度NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static byte[] generateSecretKeyEncodedBytes(String algorithm) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm - 算法NoSuchAlgorithmException - xxxNoSuchProviderException - xxxpublic static byte[] encrypt(Cipher cipher, Key key, AlgorithmParameterSpec algorithmParameterSpec, byte[] content) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException
cipher - cipherkey - keyalgorithmParameterSpec - 算法参数content - 要加密的内容InvalidKeyException - xxxBadPaddingException - xxxIllegalBlockSizeException - xxxInvalidAlgorithmParameterException - xxxpublic static byte[] encrypt(Cipher cipher, Key key, byte[] content) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException
cipher - cipherkey - keycontent - 要加密的内容InvalidKeyException - xxxBadPaddingException - xxxIllegalBlockSizeException - xxxInvalidAlgorithmParameterException - xxxpublic static byte[] decrypt(Cipher cipher, Key key, AlgorithmParameterSpec algorithmParameterSpec, byte[] content) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException
cipher - cipherkey - keyalgorithmParameterSpec - xxxcontent - 要解密的内容InvalidKeyException - xxxBadPaddingException - xxxIllegalBlockSizeException - xxxInvalidAlgorithmParameterException - xxxpublic static byte[] decrypt(Cipher cipher, Key key, byte[] content) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException
cipher - cipherkey - keycontent - 要解密的内容InvalidKeyException - xxxBadPaddingException - xxxIllegalBlockSizeException - xxxInvalidAlgorithmParameterException - xxxpublic static AlgorithmParameterGenerator generateAlgorithmParameterGenerator(String algorithm) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static AlgorithmParameters generateAlgorithmParameters(String algorithm, int length) throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static AlgorithmParameterSpec generateAlgorithmParameterSpec(String algorithm, int length, Class<? extends AlgorithmParameterSpec> type) throws NoSuchAlgorithmException, InvalidParameterSpecException
public static byte[] generateSeedBytes(int length)
length - xxxpublic static Mac generateMac(String algorithm, Key secretKey) throws NoSuchAlgorithmException, InvalidKeyException
public static Signature generateSenderSignature(String algorithm, PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeyException
public static byte[] signData(String algorithm, PrivateKey privateKey, byte[] content) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException
public static Signature generateReceiverSignature(String algorithm, PublicKey publicKey) throws NoSuchAlgorithmException, InvalidKeyException
public static boolean verifySign(String algorithm, PublicKey publicKey, byte[] content, byte[] sign) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException
Copyright © 2019. All rights reserved.