类 VerificationUtils
java.lang.Object
com.publiccms.common.tools.VerificationUtils
安全验证工具类
VerificationUtils
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static byte[]base64Decode(String input) base64解密static Stringbase64Encode(byte[] input) base64加密static StringbyteToHex(byte[] buffer) static Stringdecrypt3DES(byte[] input, String key) 已过时。static StringdecryptAES(byte[] input, String key) AES解密private static Stringstatic byte[]encryptAES(String input, String key) AES加密static KeyPairgenerateKeyPair(int keySize, SecureRandom secrand) 生成公钥私钥对private static PrivateKeygetPrivateKey(byte[] privateKey) 获取私钥对象private static PublicKeygetPublicKey(byte[] publicKey) 获取公钥对象static StringgetRandomNumber(int length) static StringgetRandomString(String text, int length) static Stringmd5加密static byte[]privateKeySign(byte[] privateKey, byte[] data) 私钥签名static booleanpublicKeyVerify(byte[] publicKey, byte[] data, byte[] sign) 公钥验证签名static Stringsha1Encode(String input) sha1加密static Stringsha256Encode(String input) sha256加密static Stringsha512Encode(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
- 抛出:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
getPrivateKey
private static PrivateKey getPrivateKey(byte[] privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException 获取私钥对象- 参数:
privateKey-- 返回:
- private key
- 抛出:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
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
-