public class SecureUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_KEY_SIZE
默认密钥字节数
RSA/DSA
Default Keysize 1024
Keysize must be a multiple of 64, ranging from 512 to 1024 (inclusive).
|
static String |
HUTOOL_CRYPTO_DECODE_HEX
Hutool自定义系统属性:是否解码Hex字符 issue#I90M9D
|
| Constructor and Description |
|---|
SecureUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addProvider(Provider provider)
增加加密解密的算法提供者,默认优先使用,例如:
addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
static AES |
aes()
AES加密,生成随机KEY。
|
static AES |
aes(byte[] key)
AES加密
例: AES加密:aes(key).encrypt(data) AES解密:aes(key).decrypt(data) |
static Cipher |
createCipher(String algorithm)
创建
Cipher |
static MessageDigest |
createJdkMessageDigest(String algorithm)
创建
MessageDigest,使用JDK默认的Provider |
static Mac |
createMac(String algorithm)
创建
Mac |
static MessageDigest |
createMessageDigest(String algorithm)
|
static Signature |
createSignature(String algorithm)
|
static byte[] |
decode(String key)
解码字符串密钥,可支持的编码如下:
1.
|
static DES |
des()
DES加密,生成随机KEY。
|
static DES |
des(byte[] key)
DES加密
例: DES加密:des(key).encrypt(data) DES解密:des(key).decrypt(data) |
static DESede |
desede()
DESede加密(又名3DES、TripleDES),生成随机KEY。
|
static DESede |
desede(byte[] key)
DESede加密(又名3DES、TripleDES)
Java中默认实现为:DESede/ECB/PKCS5Padding 例: DESede加密:desede(key).encrypt(data) DESede解密:desede(key).decrypt(data) |
static void |
disableBouncyCastle()
强制关闭Bouncy Castle库的使用,全局有效
|
static FPE |
fpe(FPE.FPEMode mode,
byte[] key,
org.bouncycastle.crypto.AlphabetMapper mapper,
byte[] tweak)
FPE(Format Preserving Encryption)实现,支持FF1和FF3-1模式。
|
static String |
generateAlgorithm(AsymmetricAlgorithm asymmetricAlgorithm,
DigestAlgorithm digestAlgorithm)
生成算法,格式为XXXwithXXX
|
static SecretKey |
generateDESKey(String algorithm,
byte[] key)
生成
SecretKey |
static SecretKey |
generateKey(String algorithm)
生成
SecretKey,仅用于对称加密和摘要算法密钥生成 |
static SecretKey |
generateKey(String algorithm,
byte[] key)
生成
SecretKey,仅用于对称加密和摘要算法密钥生成 |
static SecretKey |
generateKey(String algorithm,
int keySize)
生成
SecretKey,仅用于对称加密和摘要算法密钥生成 |
static SecretKey |
generateKey(String algorithm,
KeySpec keySpec)
生成
SecretKey,仅用于对称加密和摘要算法 |
static KeyPair |
generateKeyPair(String algorithm)
生成用于非对称加密的公钥和私钥,仅用于非对称加密
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator |
static KeyPair |
generateKeyPair(String algorithm,
AlgorithmParameterSpec params)
生成用于非对称加密的公钥和私钥
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator |
static KeyPair |
generateKeyPair(String algorithm,
byte[] seed,
AlgorithmParameterSpec params)
生成用于非对称加密的公钥和私钥
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator |
static KeyPair |
generateKeyPair(String algorithm,
int keySize)
生成用于非对称加密的公钥和私钥
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator |
static KeyPair |
generateKeyPair(String algorithm,
int keySize,
byte[] seed)
生成用于非对称加密的公钥和私钥
密钥对生成算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyPairGenerator |
static SecretKey |
generatePBEKey(String algorithm,
char[] key)
生成PBE
SecretKey |
static PrivateKey |
generatePrivateKey(KeyStore keyStore,
String alias,
char[] password)
生成私钥,仅用于非对称加密
|
static PrivateKey |
generatePrivateKey(String algorithm,
byte[] key)
生成私钥,仅用于非对称加密
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory |
static PrivateKey |
generatePrivateKey(String algorithm,
KeySpec keySpec)
生成私钥,仅用于非对称加密
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory |
static PublicKey |
generatePublicKey(String algorithm,
byte[] key)
生成公钥,仅用于非对称加密
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory |
static PublicKey |
generatePublicKey(String algorithm,
KeySpec keySpec)
生成公钥,仅用于非对称加密
算法见:https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#KeyFactory |
static Signature |
generateSignature(AsymmetricAlgorithm asymmetricAlgorithm,
DigestAlgorithm digestAlgorithm)
生成签名对象,仅用于非对称加密
|
static String |
getAlgorithmAfterWith(String algorithm)
获取用于密钥生成的算法
获取XXXwithXXX算法的后半部分算法,如果为ECDSA或SM2,返回算法为EC |
static Certificate |
getCertificate(KeyStore keyStore,
String alias)
获得 Certification
|
static HMac |
hmac(HmacAlgorithm algorithm,
byte[] key)
创建HMac对象,调用digest方法可获得hmac值
|
static HMac |
hmac(HmacAlgorithm algorithm,
SecretKey key)
创建HMac对象,调用digest方法可获得hmac值
|
static HMac |
hmac(HmacAlgorithm algorithm,
String key)
创建HMac对象,调用digest方法可获得hmac值
|
static HMac |
hmacMd5()
HmacMD5加密器,生成随机KEY
例: HmacMD5加密:hmacMd5().digest(data) HmacMD5加密并转为16进制字符串:hmacMd5().digestHex(data) |
static HMac |
hmacMd5(byte[] key)
HmacMD5加密器
例: HmacMD5加密:hmacMd5(key).digest(data) HmacMD5加密并转为16进制字符串:hmacMd5(key).digestHex(data) |
static HMac |
hmacMd5(String key)
HmacMD5加密器
例: HmacMD5加密:hmacMd5(key).digest(data) HmacMD5加密并转为16进制字符串:hmacMd5(key).digestHex(data) |
static HMac |
hmacSha1()
HmacSHA1加密器,生成随机KEY
例: HmacSHA1加密:hmacSha1().digest(data) HmacSHA1加密并转为16进制字符串:hmacSha1().digestHex(data) |
static HMac |
hmacSha1(byte[] key)
HmacSHA1加密器
例: HmacSHA1加密:hmacSha1(key).digest(data) HmacSHA1加密并转为16进制字符串:hmacSha1(key).digestHex(data) |
static HMac |
hmacSha1(String key)
HmacSHA1加密器
例: HmacSHA1加密:hmacSha1(key).digest(data) HmacSHA1加密并转为16进制字符串:hmacSha1(key).digestHex(data) |
static HMac |
hmacSha256()
HmacSHA256加密器,生成随机KEY
例: HmacSHA256加密:hmacSha256().digest(data) HmacSHA256加密并转为16进制字符串:hmacSha256().digestHex(data) |
static HMac |
hmacSha256(byte[] key)
HmacSHA256加密器
例: HmacSHA256加密:hmacSha256(key).digest(data) HmacSHA256加密并转为16进制字符串:hmacSha256(key).digestHex(data) |
static HMac |
hmacSha256(String key)
HmacSHA256加密器
例: HmacSHA256加密:hmacSha256(key).digest(data) HmacSHA256加密并转为16进制字符串:hmacSha256(key).digestHex(data) |
static MD5 |
md5()
MD5加密
例: MD5加密:md5().digest(data) MD5加密并转为16进制字符串:md5().digestHex(data) |
static String |
md5(File dataFile)
MD5加密文件,生成16进制MD5字符串
|
static String |
md5(InputStream data)
MD5加密,生成16进制MD5字符串
|
static String |
md5(String data)
MD5加密,生成16进制MD5字符串
|
static String |
pbkdf2(char[] password,
byte[] salt)
PBKDF2加密密码
|
static RC4 |
rc4(String key)
RC4算法
|
static Certificate |
readCertificate(String type,
InputStream in)
读取Certification文件
Certification为证书文件 see: http://snowolf.iteye.com/blog/391931 |
static Certificate |
readCertificate(String type,
InputStream in,
char[] password,
String alias)
读取Certification文件
Certification为证书文件 see: http://snowolf.iteye.com/blog/391931 |
static KeyStore |
readJKSKeyStore(InputStream in,
char[] password)
读取密钥库(Java Key Store,JKS) KeyStore文件
KeyStore文件用于数字证书的密钥对保存 see: http://snowolf.iteye.com/blog/391931 |
static KeyStore |
readKeyStore(String type,
InputStream in,
char[] password)
读取KeyStore文件
KeyStore文件用于数字证书的密钥对保存 see: http://snowolf.iteye.com/blog/391931 |
static Certificate |
readX509Certificate(InputStream in)
读取X.509 Certification文件
Certification为证书文件 see: http://snowolf.iteye.com/blog/391931 |
static Certificate |
readX509Certificate(InputStream in,
char[] password,
String alias)
读取X.509 Certification文件
Certification为证书文件 see: http://snowolf.iteye.com/blog/391931 |
static RSA |
rsa()
创建RSA算法对象
生成新的私钥公钥对 |
static RSA |
rsa(byte[] privateKey,
byte[] publicKey)
创建RSA算法对象
私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密 |
static RSA |
rsa(String privateKeyBase64,
String publicKeyBase64)
创建RSA算法对象
私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做加密或者解密 |
static Digester |
sha1()
SHA1加密
例: SHA1加密:sha1().digest(data) SHA1加密并转为16进制字符串:sha1().digestHex(data) |
static String |
sha1(File dataFile)
SHA1加密文件,生成16进制SHA1字符串
|
static String |
sha1(InputStream data)
SHA1加密,生成16进制SHA1字符串
|
static String |
sha1(String data)
SHA1加密,生成16进制SHA1字符串
|
static Digester |
sha256()
SHA256加密
例: SHA256加密:sha256().digest(data) SHA256加密并转为16进制字符串:sha256().digestHex(data) |
static String |
sha256(File dataFile)
SHA256加密文件,生成16进制SHA256字符串
|
static String |
sha256(InputStream data)
SHA256加密,生成16进制SHA256字符串
|
static String |
sha256(String data)
SHA256加密,生成16进制SHA256字符串
|
static Sign |
sign(SignAlgorithm algorithm)
创建签名算法对象
生成新的私钥公钥对 |
static Sign |
sign(SignAlgorithm algorithm,
byte[] privateKey,
byte[] publicKey)
创建Sign算法对象
私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证 |
static Sign |
sign(SignAlgorithm algorithm,
String privateKeyBase64,
String publicKeyBase64)
创建签名算法对象
私钥和公钥同时为空时生成一对新的私钥和公钥 私钥和公钥可以单独传入一个,如此则只能使用此钥匙来做签名或验证 |
static String |
signParams(DigestAlgorithm digestAlgorithm,
Map<?,?> params,
String... otherParams)
对参数做签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 拼接后的字符串键值对之间无符号,键值对之间无符号,忽略null值 |
static String |
signParams(DigestAlgorithm digestAlgorithm,
Map<?,?> params,
String separator,
String keyValueSeparator,
boolean isIgnoreNull,
String... otherParams)
对参数做签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 |
static String |
signParams(SymmetricCrypto crypto,
Map<?,?> params,
String... otherParams)
对参数做签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 拼接后的字符串键值对之间无符号,键值对之间无符号,忽略null值 |
static String |
signParams(SymmetricCrypto crypto,
Map<?,?> params,
String separator,
String keyValueSeparator,
boolean isIgnoreNull,
String... otherParams)
对参数做签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 |
static String |
signParamsMd5(Map<?,?> params,
String... otherParams)
对参数做md5签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 拼接后的字符串键值对之间无符号,键值对之间无符号,忽略null值 |
static String |
signParamsSha1(Map<?,?> params,
String... otherParams)
对参数做Sha1签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 拼接后的字符串键值对之间无符号,键值对之间无符号,忽略null值 |
static String |
signParamsSha256(Map<?,?> params,
String... otherParams)
对参数做Sha256签名
参数签名为对Map参数按照key的顺序排序后拼接为字符串,然后根据提供的签名算法生成签名字符串 拼接后的字符串键值对之间无符号,键值对之间无符号,忽略null值 |
static ZUC |
zuc128(byte[] key,
byte[] iv)
祖冲之算法集(ZUC-128算法)实现,基于BouncyCastle实现。
|
static ZUC |
zuc256(byte[] key,
byte[] iv)
祖冲之算法集(ZUC-256算法)实现,基于BouncyCastle实现。
|
public static String HUTOOL_CRYPTO_DECODE_HEX
public static final int DEFAULT_KEY_SIZE
RSA/DSA Default Keysize 1024 Keysize must be a multiple of 64, ranging from 512 to 1024 (inclusive).
public static SecretKey generateKey(String algorithm)
SecretKey,仅用于对称加密和摘要算法密钥生成algorithm - 算法,支持PBE算法SecretKeypublic static SecretKey generateKey(String algorithm, int keySize)
SecretKey,仅用于对称加密和摘要算法密钥生成algorithm - 算法,支持PBE算法keySize - 密钥长度SecretKeypublic static SecretKey generateKey(String algorithm, byte[] key)
SecretKey,仅用于对称加密和摘要算法密钥生成algorithm - 算法key - 密钥,如果为null 自动生成随机密钥SecretKeypublic static SecretKey generateDESKey(String algorithm, byte[] key)
SecretKeyalgorithm - DES算法,包括DES、DESede等key - 密钥SecretKeypublic static SecretKey generatePBEKey(String algorithm, char[] key)
SecretKeyalgorithm - PBE算法,包括:PBEWithMD5AndDES、PBEWithSHA1AndDESede、PBEWithSHA1AndRC2_40等key - 密钥SecretKeypublic static SecretKey generateKey(String algorithm, KeySpec keySpec)
SecretKey,仅用于对称加密和摘要算法public static PrivateKey generatePrivateKey(String algorithm, byte[] key)
algorithm - 算法key - 密钥PrivateKeypublic static PrivateKey generatePrivateKey(String algorithm, KeySpec keySpec)
algorithm - 算法keySpec - KeySpecPrivateKeypublic static PrivateKey generatePrivateKey(KeyStore keyStore, String alias, char[] password)
keyStore - KeyStorealias - 别名password - 密码PrivateKeypublic static PublicKey generatePublicKey(String algorithm, byte[] key)
algorithm - 算法key - 密钥PublicKeypublic static PublicKey generatePublicKey(String algorithm, KeySpec keySpec)
public static KeyPair generateKeyPair(String algorithm)
algorithm - 非对称加密算法KeyPairpublic static KeyPair generateKeyPair(String algorithm, int keySize)
algorithm - 非对称加密算法keySize - 密钥模(modulus )长度KeyPairpublic static KeyPair generateKeyPair(String algorithm, int keySize, byte[] seed)
algorithm - 非对称加密算法keySize - 密钥模(modulus )长度seed - 种子KeyPairpublic static KeyPair generateKeyPair(String algorithm, AlgorithmParameterSpec params)
algorithm - 非对称加密算法params - AlgorithmParameterSpecKeyPairpublic static KeyPair generateKeyPair(String algorithm, byte[] seed, AlgorithmParameterSpec params)
algorithm - 非对称加密算法seed - 种子params - AlgorithmParameterSpecKeyPairpublic static String getAlgorithmAfterWith(String algorithm)
algorithm - XXXwithXXX算法public static String generateAlgorithm(AsymmetricAlgorithm asymmetricAlgorithm, DigestAlgorithm digestAlgorithm)
asymmetricAlgorithm - 非对称算法digestAlgorithm - 摘要算法public static Signature generateSignature(AsymmetricAlgorithm asymmetricAlgorithm, DigestAlgorithm digestAlgorithm)
asymmetricAlgorithm - AsymmetricAlgorithm 非对称加密算法digestAlgorithm - DigestAlgorithm 摘要算法Signaturepublic static KeyStore readJKSKeyStore(InputStream in, char[] password)
in - InputStream 如果想从文件读取.keystore文件,使用 FileUtil.getInputStream(java.io.File) 读取password - 密码KeyStorepublic static KeyStore readKeyStore(String type, InputStream in, char[] password)
type - 类型in - InputStream 如果想从文件读取.keystore文件,使用 FileUtil.getInputStream(java.io.File) 读取password - 密码KeyStorepublic static Certificate readX509Certificate(InputStream in, char[] password, String alias)
in - InputStream 如果想从文件读取.cer文件,使用 FileUtil.getInputStream(java.io.File) 读取password - 密码alias - 别名KeyStorepublic static Certificate readX509Certificate(InputStream in)
in - InputStream 如果想从文件读取.cer文件,使用 FileUtil.getInputStream(java.io.File) 读取KeyStorepublic static Certificate readCertificate(String type, InputStream in, char[] password, String alias)
type - 类型,例如X.509in - InputStream 如果想从文件读取.cer文件,使用 FileUtil.getInputStream(java.io.File) 读取password - 密码alias - 别名KeyStorepublic static Certificate readCertificate(String type, InputStream in)
type - 类型,例如X.509in - InputStream 如果想从文件读取.cer文件,使用 FileUtil.getInputStream(java.io.File) 读取Certificatepublic static Certificate getCertificate(KeyStore keyStore, String alias)
keyStore - KeyStorealias - 别名Certificatepublic static AES aes(byte[] key)
AES加密:aes(key).encrypt(data) AES解密:aes(key).decrypt(data)
key - 密钥SymmetricCryptopublic static DES des(byte[] key)
DES加密:des(key).encrypt(data) DES解密:des(key).decrypt(data)
key - 密钥DESpublic static DESede desede()
DESede对象或者使用相同KEYDESede加密:desede().encrypt(data) DESede解密:desede().decrypt(data)
DESedepublic static DESede desede(byte[] key)
DESede加密:desede(key).encrypt(data) DESede解密:desede(key).decrypt(data)
key - 密钥DESedepublic static MD5 md5()
MD5加密:md5().digest(data) MD5加密并转为16进制字符串:md5().digestHex(data)
Digesterpublic static String md5(InputStream data)
data - 数据public static String md5(File dataFile)
dataFile - 被加密文件public static Digester sha1()
Digesterpublic static String sha1(String data)
data - 数据public static String sha1(InputStream data)
data - 数据public static String sha1(File dataFile)
dataFile - 被加密文件public static Digester sha256()
Digesterpublic static String sha256(String data)
data - 数据public static String sha256(InputStream data)
data - 数据public static String sha256(File dataFile)
dataFile - 被加密文件public static HMac hmac(HmacAlgorithm algorithm, String key)
algorithm - HmacAlgorithmkey - 密钥,如果为null生成随机密钥HMacpublic static HMac hmac(HmacAlgorithm algorithm, byte[] key)
algorithm - HmacAlgorithmkey - 密钥,如果为null生成随机密钥HMacpublic static HMac hmac(HmacAlgorithm algorithm, SecretKey key)
algorithm - HmacAlgorithmkey - 密钥SecretKey,如果为null生成随机密钥HMacpublic static HMac hmacMd5(String key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacMd5(byte[] key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacMd5()
HMacpublic static HMac hmacSha1(String key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacSha1(byte[] key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacSha1()
HMacpublic static HMac hmacSha256(String key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacSha256(byte[] key)
key - 加密密钥,如果为null生成随机密钥HMacpublic static HMac hmacSha256()
HMacpublic static RSA rsa(String privateKeyBase64, String publicKeyBase64)
privateKeyBase64 - 私钥Base64publicKeyBase64 - 公钥Base64RSApublic static RSA rsa(byte[] privateKey, byte[] publicKey)
privateKey - 私钥publicKey - 公钥RSApublic static Sign sign(SignAlgorithm algorithm)
algorithm - 签名算法Signpublic static Sign sign(SignAlgorithm algorithm, String privateKeyBase64, String publicKeyBase64)
algorithm - 签名算法privateKeyBase64 - 私钥Base64publicKeyBase64 - 公钥Base64Signpublic static Sign sign(SignAlgorithm algorithm, byte[] privateKey, byte[] publicKey)
algorithm - 算法枚举privateKey - 私钥publicKey - 公钥Signpublic static String signParams(SymmetricCrypto crypto, Map<?,?> params, String... otherParams)
crypto - 对称加密算法params - 参数otherParams - 其它附加参数字符串(例如密钥)public static String signParams(SymmetricCrypto crypto, Map<?,?> params, String separator, String keyValueSeparator, boolean isIgnoreNull, String... otherParams)
crypto - 对称加密算法params - 参数separator - entry之间的连接符keyValueSeparator - kv之间的连接符isIgnoreNull - 是否忽略null的键和值otherParams - 其它附加参数字符串(例如密钥)public static String signParamsMd5(Map<?,?> params, String... otherParams)
params - 参数otherParams - 其它附加参数字符串(例如密钥)public static String signParamsSha1(Map<?,?> params, String... otherParams)
params - 参数otherParams - 其它附加参数字符串(例如密钥)public static String signParamsSha256(Map<?,?> params, String... otherParams)
params - 参数otherParams - 其它附加参数字符串(例如密钥)public static String signParams(DigestAlgorithm digestAlgorithm, Map<?,?> params, String... otherParams)
digestAlgorithm - 摘要算法params - 参数otherParams - 其它附加参数字符串(例如密钥)public static String signParams(DigestAlgorithm digestAlgorithm, Map<?,?> params, String separator, String keyValueSeparator, boolean isIgnoreNull, String... otherParams)
digestAlgorithm - 摘要算法params - 参数separator - entry之间的连接符keyValueSeparator - kv之间的连接符isIgnoreNull - 是否忽略null的键和值otherParams - 其它附加参数字符串(例如密钥)public static void addProvider(Provider provider)
addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
provider - 算法提供者public static byte[] decode(String key)
1. Hex(16进制)编码 1. Base64编码
key - 被解码的密钥字符串public static Cipher createCipher(String algorithm)
Cipheralgorithm - 算法Cipherpublic static MessageDigest createMessageDigest(String algorithm)
algorithm - 算法MessageDigestpublic static MessageDigest createJdkMessageDigest(String algorithm)
MessageDigest,使用JDK默认的Provideralgorithm - 算法MessageDigestpublic static Mac createMac(String algorithm)
Macalgorithm - 算法Macpublic static Signature createSignature(String algorithm)
algorithm - 算法Signaturepublic static void disableBouncyCastle()
public static String pbkdf2(char[] password, byte[] salt)
password - 密码salt - 盐public static FPE fpe(FPE.FPEMode mode, byte[] key, org.bouncycastle.crypto.AlphabetMapper mapper, byte[] tweak)
mode - FPE模式枚举,可选FF1或FF3-1key - 密钥,null表示随机密钥,长度必须是16bit、24bit或32bitmapper - Alphabet字典映射,被加密的字符范围和这个映射必须一致,例如手机号、银行卡号等字段可以采用数字字母字典表tweak - Tweak是为了解决因局部加密而导致结果冲突问题,通常情况下将数据的不可变部分作为TweakFPEpublic static ZUC zuc128(byte[] key, byte[] iv)
key - 密钥iv - 加盐,长度16bytes,null是随机加盐ZUCCopyright © 2025. All rights reserved.