类 VerificationUtils

java.lang.Object
com.publiccms.common.tools.VerificationUtils

public class VerificationUtils extends Object
安全验证工具类 VerificationUtils
  • 字段详细资料

    • iv

      private static byte[] iv
  • 构造器详细资料

    • VerificationUtils

      private VerificationUtils()
  • 方法详细资料

    • getRandomString

      public static String getRandomString(String text, int length)
      参数:
      text -
      length -
      返回:
      random string
    • getRandomNumber

      public static String getRandomNumber(int length)
      参数:
      length -
      返回:
      random number
    • generateKeyPair

      public static KeyPair generateKeyPair(int keySize, SecureRandom secrand)
      生成公钥私钥对
      参数:
      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

      public static String md5Encode(String input)
      md5加密
      参数:
      input -
      返回:
      md5 encode result
    • sha1Encode

      public static String sha1Encode(String input)
      sha1加密
      参数:
      input -
      返回:
      sha1 encode result
    • base64Encode

      public static String base64Encode(byte[] input)
      base64加密
      参数:
      input -
      返回:
      base64 encode result
    • encode

      private static String encode(String input, String type)
    • base64Decode

      public static byte[] base64Decode(String input)
      base64解密
      参数:
      input -
      返回:
      base64 decode result
    • sha512Encode

      public static String sha512Encode(String input)
      sha512加密
      参数:
      input -
      返回:
      sha2 encode result
    • sha256Encode

      public static String sha256Encode(String input)
      sha256加密
      参数:
      input -
      返回:
      sha2 encode result
    • encryptAES

      public static byte[] encryptAES(String input, String key)
      AES加密
      参数:
      input -
      key -
      返回:
      AES encode result
    • decryptAES

      public static String decryptAES(byte[] input, String key)
      AES解密
      参数:
      input -
      key -
      返回:
      3-DES decode result
    • decrypt3DES

      @Deprecated public static String decrypt3DES(byte[] input, String key)
      已过时。
      3-DES解密
      参数:
      input -
      key -
      返回:
      3-DES decode result
    • byteToHex

      public static String byteToHex(byte[] buffer)
      参数:
      buffer -
      返回:
      hex