类 VerificationUtils
java.lang.Object
com.publiccms.common.tools.VerificationUtils
安全验证工具类
VerificationUtils
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static byte[]
base64Decode
(String input) base64解密static String
base64Encode
(byte[] input) base64加密static String
byteToHex
(byte[] buffer) static String
decrypt3DES
(byte[] input, String key) 已过时。static String
decryptAES
(byte[] input, String key) AES解密private static String
static byte[]
encryptAES
(String input, String key) AES加密static KeyPair
generateKeyPair
(int keySize, SecureRandom secrand) 生成公钥私钥对private static PrivateKey
getPrivateKey
(byte[] privateKey) 获取私钥对象private static PublicKey
getPublicKey
(byte[] publicKey) 获取公钥对象static String
getRandomNumber
(int length) static String
getRandomString
(String text, int length) static String
md5加密static byte[]
privateKeySign
(byte[] privateKey, byte[] data) 私钥签名static boolean
publicKeyVerify
(byte[] publicKey, byte[] data, byte[] sign) 公钥验证签名static String
sha1Encode
(String input) sha1加密static String
sha256Encode
(String input) sha256加密static String
sha512Encode
(String input) sha512加密
-
字段详细资料
-
iv
private static byte[] iv
-
-
构造器详细资料
-
VerificationUtils
private VerificationUtils()
-
-
方法详细资料
-
getRandomString
- 参数:
text
-length
-- 返回:
- random string
-
getRandomNumber
- 参数:
length
-- 返回:
- random number
-
generateKeyPair
生成公钥私钥对- 参数:
keySize
-secrand
-- 返回:
- key pair
-
getPublicKey
private static PublicKey getPublicKey(byte[] publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException 获取公钥对象- 参数:
publicKey
-- 返回:
- public key
- 抛出:
NoSuchAlgorithmException
InvalidKeySpecException
-
getPrivateKey
private static PrivateKey getPrivateKey(byte[] privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException 获取私钥对象- 参数:
privateKey
-- 返回:
- private key
- 抛出:
NoSuchAlgorithmException
InvalidKeySpecException
-
publicKeyVerify
public static boolean publicKeyVerify(byte[] publicKey, byte[] data, byte[] sign) 公钥验证签名- 参数:
publicKey
-data
-sign
-- 返回:
- whether public key verify is passed
-
privateKeySign
public static byte[] privateKeySign(byte[] privateKey, byte[] data) 私钥签名- 参数:
privateKey
-data
-- 返回:
- private key sign
-
md5Encode
md5加密- 参数:
input
-- 返回:
- md5 encode result
-
sha1Encode
sha1加密- 参数:
input
-- 返回:
- sha1 encode result
-
base64Encode
base64加密- 参数:
input
-- 返回:
- base64 encode result
-
encode
-
base64Decode
base64解密- 参数:
input
-- 返回:
- base64 decode result
-
sha512Encode
sha512加密- 参数:
input
-- 返回:
- sha2 encode result
-
sha256Encode
sha256加密- 参数:
input
-- 返回:
- sha2 encode result
-
encryptAES
AES加密- 参数:
input
-key
-- 返回:
- AES encode result
-
decryptAES
AES解密- 参数:
input
-key
-- 返回:
- 3-DES decode result
-
decrypt3DES
已过时。3-DES解密- 参数:
input
-key
-- 返回:
- 3-DES decode result
-
byteToHex
- 参数:
buffer
-- 返回:
- hex
-