public class Ciphers extends Securitys
| 限定符 | 构造器和说明 |
|---|---|
protected |
Ciphers() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addDefaultTransformation(String algorithm,
String transformation) |
static String |
createAlgorithmTransformation(String transformation)
https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html#trans
transformation 有两种形式:
1) 只有algorithm name
2) 由3部分构成:{algorithm name}/{mode}/padding
|
static String |
createAlgorithmTransformation(String algorithm,
String mode,
String padding) |
static Cipher |
createCipher(String algorithmTransformation,
Provider provider,
int operateMode,
Certificate certificate,
SecureRandom secureRandom) |
static Cipher |
createCipher(String algorithmTransformation,
Provider provider,
int operateMode,
Key key,
AlgorithmParameterSpec parameterSpec,
SecureRandom secureRandom)
如果在初始化 Cipher过程中,出现了java.security.InvalidKeyException: Illegal key size
可以找到 ${JDK_HOME}/jre/lib/security/java.security, 将 crypto.policy 设置为 unlimited
|
static Cipher |
createCipher(String algorithmTransformation,
Provider provider,
int operateMode,
Key key,
AlgorithmParameters parameters,
SecureRandom secureRandom)
如果在初始化 Cipher过程中,出现了java.security.InvalidKeyException: Illegal key size
可以找到 ${JDK_HOME}/jre/lib/security/java.security, 将 crypto.policy 设置为 unlimited
|
static Cipher |
createCipher(String algorithmTransformation,
Provider provider,
int operateMode,
Key key,
SecureRandom secureRandom)
如果在初始化 Cipher过程中,出现了java.security.InvalidKeyException: Illegal key size
可以找到 ${JDK_HOME}/jre/lib/security/java.security, 将 crypto.policy 设置为 unlimited
|
static Cipher |
createEmptyCipher(String algorithmTransformation,
Provider provider) |
static byte[] |
decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier) |
static byte[] |
decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameters parameters) |
static byte[] |
decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSpec parameterSpec) |
static byte[] |
decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSupplier parameterSupplier) |
static byte[] |
decrypt(Cipher cipher,
byte[] data) |
static byte[] |
doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSpec parameterSpec,
boolean encrypt) |
static byte[] |
doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSupplier parameterSupplier,
boolean encrypt) |
static byte[] |
doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
boolean encrypt) |
static byte[] |
encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier) |
static byte[] |
encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameters parameters) |
static byte[] |
encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSpec parameterSpec) |
static byte[] |
encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
BytesBasedKeySupplier keySupplier,
AlgorithmParameterSupplier parameterSupplier) |
static byte[] |
encrypt(Cipher cipher,
byte[] data) |
static String |
extractAlgorithm(String transformation) |
static String |
extractCipherAlgorithm(String algorithm)
获取用于密钥生成的算法
获取XXXwithXXX算法,这种算法通常是 签名算法,with 前面部分是摘要算法或者None,with 后面部分是 加密算法,通常是非对称加密算法。 |
static Symmetrics.MODE |
extractSymmetricMode(String algorithmTransformation) |
static CipherAlgorithmSuiteRegistry |
getAlgorithmSuiteRegistry() |
static String |
getDefaultTransformation(String algorithm) |
addProvider, getLangxSecurityProvider, getProvider, getSecureRandom, insertProvider, insertProviderAt, langxProviderInstalled, loadLangxProvider, setuppublic static void addDefaultTransformation(String algorithm, String transformation)
public static Cipher createEmptyCipher(@NonNull String algorithmTransformation, @Nullable Provider provider)
public static Cipher createCipher(@NonNull String algorithmTransformation, @Nullable Provider provider, int operateMode, Key key, SecureRandom secureRandom)
public static Cipher createCipher(@NonNull String algorithmTransformation, @Nullable Provider provider, int operateMode, Key key, @Nullable AlgorithmParameterSpec parameterSpec, SecureRandom secureRandom)
public static Cipher createCipher(@NonNull String algorithmTransformation, @Nullable Provider provider, int operateMode, Key key, @Nullable AlgorithmParameters parameters, SecureRandom secureRandom)
public static Cipher createCipher(@NonNull String algorithmTransformation, @Nullable Provider provider, int operateMode, Certificate certificate, SecureRandom secureRandom)
public static byte[] encrypt(Cipher cipher, byte[] data)
public static byte[] decrypt(Cipher cipher, byte[] data)
public static byte[] encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier)
public static byte[] encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSpec parameterSpec)
public static byte[] encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameters parameters)
public static byte[] encrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSupplier parameterSupplier)
public static byte[] decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier)
public static byte[] decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSpec parameterSpec)
public static byte[] decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameters parameters)
public static byte[] decrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSupplier parameterSupplier)
public static byte[] doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
boolean encrypt)
public static byte[] doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSpec parameterSpec,
boolean encrypt)
public static byte[] doEncryptOrDecrypt(byte[] bytes,
byte[] keyBytes,
String algorithm,
String algorithmTransformation,
Provider provider,
SecureRandom secureRandom,
@NonNull
BytesBasedKeySupplier keySupplier,
@Nullable
AlgorithmParameterSupplier parameterSupplier,
boolean encrypt)
public static String createAlgorithmTransformation(String transformation)
transformation 有两种形式:
1) 只有algorithm name
2) 由3部分构成:{algorithm name}/{mode}/padding
public static String createAlgorithmTransformation(@NotEmpty String algorithm, @NotEmpty String mode, @NotEmpty String padding)
public static Symmetrics.MODE extractSymmetricMode(String algorithmTransformation)
public static String extractCipherAlgorithm(String algorithm)
algorithm - XXXwithXXX算法public static CipherAlgorithmSuiteRegistry getAlgorithmSuiteRegistry()
Copyright © 2022. All rights reserved.