类 CryptoUtils

java.lang.Object
com.baomidou.dynamic.datasource.toolkit.CryptoUtils

public class CryptoUtils extends Object
Copyright 1999-2018 Alibaba Group Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

作者:
alibaba
  • 字段详细资料

    • DEFAULT_PUBLIC_KEY_STRING

      public static final String DEFAULT_PUBLIC_KEY_STRING
      另请参阅:
  • 构造器详细资料

    • CryptoUtils

      public CryptoUtils()
  • 方法详细资料

    • decrypt

      public static String decrypt(String cipherText) throws Exception
      加密算法RSA
      参数:
      cipherText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • decrypt

      public static String decrypt(String publicKeyText, String cipherText) throws Exception
      加密算法RSA
      参数:
      publicKeyText - 公钥
      cipherText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • getPublicKeyByX509

      public static PublicKey getPublicKeyByX509(String x509File)
      加密算法RSA
      参数:
      x509File - 公钥文件
      返回:
      加密后的字符串
    • getPublicKey

      public static PublicKey getPublicKey(String publicKeyText)
      加密算法RSA
      参数:
      publicKeyText - 公钥
      返回:
      加密后的字符串
    • getPublicKeyByPublicKeyFile

      public static PublicKey getPublicKeyByPublicKeyFile(String publicKeyFile)
      加密算法RSA
      参数:
      publicKeyFile - 公钥文件
      返回:
      加密后的字符串
    • decrypt

      public static String decrypt(PublicKey publicKey, String cipherText) throws Exception
      加密算法RSA
      参数:
      publicKey - 公钥
      cipherText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • encrypt

      public static String encrypt(String plainText) throws Exception
      加密算法RSA
      参数:
      plainText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • encrypt

      public static String encrypt(String key, String plainText) throws Exception
      加密算法RSA
      参数:
      key - 加密的密钥
      plainText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • encrypt

      public static String encrypt(byte[] keyBytes, String plainText) throws Exception
      加密算法RSA
      参数:
      keyBytes - 加密的密钥
      plainText - 需要加密的字符串
      返回:
      加密后的字符串
      抛出:
      Exception - 加密过程中的异常信息
    • genKeyPairBytes

      public static byte[][] genKeyPairBytes(int keySize)
      生成密钥对
      参数:
      keySize - 密钥对长度
      返回:
      密钥对
    • genKeyPair

      public static String[] genKeyPair(int keySize)
      生成密钥对
      参数:
      keySize - 密钥对长度
      返回:
      Base64编码后的密钥对