gboat2.base.bridge.util.security
类 RSAUtil

java.lang.Object
  继承者 gboat2.base.bridge.util.security.RSAUtil

public class RSAUtil
extends Object

RSA 加密、解密的工具类。如果需要与 .NET 平台进行 RSA 加密解密交互,请将加解密的 transformation 参数使用 "RSA/ECB/PKCS1Padding"

进行加解密操作时需要使用的 transformation 参数的格式为 "Algorithm/Modes/Paddings",如:RSA/ECB/PKCS1Padding。RSA 加解密 Algorithm 为 RSA,Modes 的值只能是 ECB,Paddings 的可选值有: NOPADDING, PKCS1PADDING, OAEPWITHMD5ANDMGF1PADDING, OAEPWITHSHA1ANDMGF1PADDING, OAEPWITHSHA-1ANDMGF1PADDING, OAEPWITHSHA-256ANDMGF1PADDING, OAEPWITHSHA-384ANDMGF1PADDING, OAEPWITHSHA-512ANDMGF1PADDING
更多关于 transformation 参数的资料请参考 Java Cryptography Architecture Reference Guide 页面中的附录 A。

 进行加密和解密操作的示例代码:
  
 String privateKey = "MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAL6VJN4ZkfZA3aPPgKC3xaqT/yZT5FOl"
         + "Q5TGg6heVqDVEHHVLH1E+HEEmWmuTv2ngz9pZbzy9KWkJpV59W1dgNHSSk575VjUAv0BhZXFSH0lng2m"
         + "Z2Q5/2dVxKsASjJ2bQiEGUD8LO5KpaLlfQpo3ANovBZvUtHw5exegnyXyZbDAgMBAAECgYEAr7YEWr1K"
         + "hLcDYg9jMUqd9QokOSspnTEGoPlx016/EeO/GKSJMynOwSyTYQszisvRxzoecdmyU7GHXVMnQ2Ds7Wvb"
         + "cuNkIRWmxFa4nTkk2zNF6KByvvFwLiW4LQXF6B+uV7+ZNqvfhCoD/j2wki8jfWkuuAaKnTda/axHMi+z"
         + "RYECQQD73iC2GjZyur4amJQPK6d+kDlJ0dYyyUvQa0vd6mfoPnQDOIqayBaueSwWIpLI/L7eUuP9CDFr"
         + "yQtdBvWqD/dBAkEAwbWcrybn0eaxiPZacZLZXzXO8g12hYoXT1h0DTLvy1rnVUOspNfKZcBZMjPxT4+Q"
         + "EknoTShSnSbJ5sHitfZxAwJBANMlU2z2KqEh1k77jFvvb9oVVEGDbTtkL2+JE6/1W6iB+sXcd63sgb9A"
         + "i+n+j+l4oRZGjSTJ4oyGnUUemYI5IkECQQCA9JNrcv4PGYIFCOPrCfTV0m+Dan0Fp4mfE+amRsumWEz6"
         + "0UOktdeS53s51aSG767czgDtJLPi1MjCaz6vHnHbAkEA4NxLLg6UCAoCpXMgqqZHWMgbMwNNFr9diCWP"
         + "/tZ5OJmWYHgn7zfqMXa/RNaethjdG1biIkj5h7qm6XDBBqGuxw==";
 String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+lSTeGZH2QN2jz4Cgt8Wqk/8mU+RTpUOUxoOoXlag"
         + "1RBx1Sx9RPhxBJlprk79p4M/aWW88vSlpCaVefVtXYDR0kpOe+VY1AL9AYWVxUh9JZ4NpmdkOf9nVcSr"
         + "AEoydm0IhBlA/CzuSqWi5X0KaNwDaLwWb1LR8OXsXoJ8l8mWwwIDAQAB";
 
 String data = "this is a test 中文";
 System.out.println("原文:" + data);
 System.out.println("--------------------------------------");
 
 String encrypted = encryptBase64ByPrivateKey(data, privateKey);
 System.out.println("用私钥加密:" + encrypted);
 String decrypted = new String(decryptByPublicKey(encrypted, publicKey));
 System.out.println("用公钥解密::" + decrypted);
 
 System.out.println("--------------------------------------");
 encrypted = encryptBase64ByPublicKey(data, publicKey);
 System.out.println("用公钥加密:" + encrypted);
 decrypted = new String(decryptByPrivateKey(encrypted, privateKey));
 System.out.println("用私钥解密::" + decrypted);
  
 

从以下版本开始:
3.0
作者:
何明旺
另请参见:
Base64Util, CertificateUtil, RSASignUtil

字段摘要
static String DOTNET_RSA_TRANSFORMATION
           
static String RSA
           
 
构造方法摘要
RSAUtil()
           
 
方法摘要
static byte[] decrypt(byte[] data, Key key)
          对数据进行解密
static byte[] decrypt(byte[] data, KeySpec keySpec)
          对数据进行解密
static byte[] decrypt(byte[] data, KeySpec keySpec, String transformation)
          对数据进行解密
static byte[] decrypt(byte[] encryptedData, Key key, String transformation)
          对数据进行解密
static void decrypt(File src, File dest, Key key)
          对文件进行解密
static void decrypt(File src, File dest, KeySpec keySpec)
          对文件进行解密
static void decrypt(File src, File dest, KeySpec keySpec, String transformation)
          对文件进行解密
static void decrypt(File src, File dest, Key key, String transformation)
          对文件进行解密
static byte[] decrypt(File file, Key key)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decrypt(File file, KeySpec keySpec)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decrypt(File file, KeySpec keySpec, String transformation)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decrypt(File file, Key key, String transformation)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decrypt(String data, Key key)
          对字符串进行解密
static byte[] decrypt(String data, KeySpec keySpec)
          对字符串进行解密
static byte[] decrypt(String data, KeySpec keySpec, String transformation)
          对字符串进行解密
static byte[] decrypt(String data, Key key, String transformation)
          对字符串进行解密
static byte[] decryptByPrivateKey(byte[] data, String privateKey)
          使用私钥对数据进行解密
static byte[] decryptByPrivateKey(byte[] data, String privateKey, String transformation)
          使用私钥对数据进行解密
static void decryptByPrivateKey(File src, File dest, String privateKey)
          对文件进行解密
static void decryptByPrivateKey(File src, File dest, String privateKey, String transformation)
          对文件进行解密
static byte[] decryptByPrivateKey(File file, String privateKey)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decryptByPrivateKey(File file, String privateKey, String transformation)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decryptByPrivateKey(String data, String privateKey)
          对字符串进行解密
static byte[] decryptByPrivateKey(String data, String privateKey, String transformation)
          对字符串进行解密
static byte[] decryptByPublicKey(byte[] data, String publicKey)
          使用公钥对数据进行解密
static byte[] decryptByPublicKey(byte[] data, String publicKey, String transformation)
          使用公钥对数据进行解密
static void decryptByPublicKey(File src, File dest, String publicKey)
          对文件进行解密
static void decryptByPublicKey(File src, File dest, String publicKey, String transformation)
          对文件进行解密
static byte[] decryptByPublicKey(File file, String publicKey)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decryptByPublicKey(File file, String publicKey, String transformation)
          对文件内容进行解密,文件太大可能会导致内存溢出
static byte[] decryptByPublicKey(String data, String publicKey)
          对字符串进行解密
static byte[] decryptByPublicKey(String data, String publicKey, String transformation)
          对字符串进行解密
static byte[] encrypt(byte[] data, Key key)
          对数据进行加密
static byte[] encrypt(byte[] data, KeySpec keySpec)
          对数据进行加密
static byte[] encrypt(byte[] data, KeySpec keySpec, String transformation)
          对数据进行加密
static byte[] encrypt(byte[] data, Key key, String transformation)
          对数据进行加密
static void encrypt(File src, File dest, Key key)
          对文件进行加密
static void encrypt(File src, File dest, KeySpec keySpec)
          对文件进行加密
static void encrypt(File src, File dest, KeySpec keySpec, String transformation)
          对文件进行加密
static void encrypt(File src, File dest, Key key, String transformation)
          对文件进行加密
static byte[] encrypt(File file, Key key)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encrypt(File file, KeySpec keySpec)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encrypt(File file, KeySpec keySpec, String transformation)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encrypt(File file, Key key, String transformation)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encrypt(String data, Key key)
          对字符串进行加密
static byte[] encrypt(String data, KeySpec keySpec)
          对字符串进行加密
static byte[] encrypt(String data, KeySpec keySpec, String transformation)
          对字符串进行加密
static byte[] encrypt(String data, Key key, String transformation)
          对字符串进行加密
static String encryptBase64(byte[] data, Key key)
          对数据进行加密
static String encryptBase64(byte[] data, KeySpec keySpec)
          对数据进行加密
static String encryptBase64(byte[] data, KeySpec keySpec, String transformation)
          对数据进行加密
static String encryptBase64(byte[] data, Key key, String transformation)
          对数据进行加密
static String encryptBase64(String data, Key key)
          对字符串进行加密
static String encryptBase64(String data, KeySpec keySpec)
          对字符串进行加密
static String encryptBase64(String data, KeySpec keySpec, String transformation)
          对字符串进行加密
static String encryptBase64(String data, Key key, String transformation)
          对字符串进行加密
static String encryptBase64ByPrivateKey(byte[] data, String privateKey)
          使用私钥对数据进行加密
static String encryptBase64ByPrivateKey(byte[] data, String privateKey, String transformation)
          使用私钥对数据进行加密
static String encryptBase64ByPrivateKey(String data, String privateKey)
          使用私钥对字符串进行加密
static String encryptBase64ByPrivateKey(String data, String privateKey, String transformation)
          使用私钥对字符串进行加密
static String encryptBase64ByPublicKey(byte[] data, String publicKey)
          使用公钥对数据进行加密
static String encryptBase64ByPublicKey(byte[] data, String publicKey, String transformation)
          使用公钥对数据进行加密
static String encryptBase64ByPublicKey(String data, String publicKey)
          使用公钥对字符串进行加密
static String encryptBase64ByPublicKey(String data, String publicKey, String transformation)
          使用公钥对字符串进行加密
static byte[] encryptByPrivateKey(byte[] data, String privateKey)
          使用私钥对数据进行加密
static byte[] encryptByPrivateKey(byte[] data, String privateKey, String transformation)
          使用私钥对数据进行加密
static void encryptByPrivateKey(File src, File dest, String privateKey)
          对文件进行加密
static void encryptByPrivateKey(File src, File dest, String privateKey, String transformation)
          对文件进行加密
static byte[] encryptByPrivateKey(File file, String privateKey)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encryptByPrivateKey(File file, String privateKey, String transformation)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encryptByPrivateKey(String data, String privateKey)
          对字符串进行加密
static byte[] encryptByPrivateKey(String data, String privateKey, String transformation)
          对字符串进行加密
static byte[] encryptByPublicKey(byte[] data, String publicKey)
          使用公钥对数据进行加密
static byte[] encryptByPublicKey(byte[] data, String publicKey, String transformation)
          使用公钥对数据进行加密
static void encryptByPublicKey(File src, File dest, String publicKey)
          对文件进行加密
static void encryptByPublicKey(File src, File dest, String publicKey, String transformation)
          对文件进行加密
static byte[] encryptByPublicKey(File file, String publicKey)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encryptByPublicKey(File file, String publicKey, String transformation)
          对文件内容进行加密,文件太大可能会导致内存溢出
static byte[] encryptByPublicKey(String data, String publicKey)
          对字符串进行加密
static byte[] encryptByPublicKey(String data, String publicKey, String transformation)
          对字符串进行加密
static String getDotNetRSAParametersWithPrivateKey(PrivateKey privateKey)
          Returns XML encoded RSA private key string suitable for .NET:CryptoServiceProvider.FromXmlString(true)。
static String getDotNetRSAParametersWithPublicKey(PrivateKey privateKey)
          Returns XML encoded RSA public key string suitable for .NET:CryptoServiceProvider.FromXmlString(true) Leading zero bytes (most significant) must be removed for XML encoding for .NET; otherwise format error
static KeyPair getKeyPair()
          获取密钥对
static KeyPair getKeyPair(int size)
          Generates the keys for given size.
static PrivateKey getPrivateKey(RSAPrivateKeySpec privateKeySpec)
          获取私钥
static PrivateKey getPrivateKey(String privateKeyStr)
          根据私钥字符串,获取对应的私钥实例对象
static PrivateKey getPrivateKey(String base64Modulus, String base64PublicExponent, String base64PrivateExponent, String base64PrimeP, String base64PrimeQ, String base64PrimeExponentP, String base64PrimeExponentQ, String base64CrtCoefficient)
          获取私钥
static PrivateKey getPrivateKeyFromDotNetRSAParameters(String dotnetRsaParameters)
          根据 .NET 的私钥字符串,获取对应的私钥实例对象
static PublicKey getPublicKey(RSAPublicKeySpec publicKeySpec)
          获取公钥
static PublicKey getPublicKey(String publicKeyStr)
          根据公钥字符串,获取对应的公钥实例对象
static PublicKey getPublicKey(String base64Modulus, String base64PublicExponent)
          根据公钥 n、e 生成公钥
static PublicKey getPublicKeyFromDotNetRSAParameters(String dotnetRsaParameters)
          根据 .NET 的私钥字符串,获取对应的私钥实例对象
static String getRSAPublicKeyAsNetFormat(RSAPublicKey publicKey)
          Gets the RSA Public Key.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

RSA

public static final String RSA
另请参见:
常量字段值

DOTNET_RSA_TRANSFORMATION

public static final String DOTNET_RSA_TRANSFORMATION
另请参见:
常量字段值
构造方法详细信息

RSAUtil

public RSAUtil()
方法详细信息

getKeyPair

public static KeyPair getKeyPair()
获取密钥对

返回:

getKeyPair

public static KeyPair getKeyPair(int size)
Generates the keys for given size.

参数:
size - Key Size [512|1024]

getPrivateKey

public static PrivateKey getPrivateKey(String privateKeyStr)
根据私钥字符串,获取对应的私钥实例对象

参数:
privateKeyStr - 经过 BASE64 编码后的私钥字符串
返回:

getPrivateKey

public static PrivateKey getPrivateKey(RSAPrivateKeySpec privateKeySpec)
获取私钥

参数:
privateKeySpec - RSA 专用私钥
返回:

getPrivateKey

public static PrivateKey getPrivateKey(String base64Modulus,
                                       String base64PublicExponent,
                                       String base64PrivateExponent,
                                       String base64PrimeP,
                                       String base64PrimeQ,
                                       String base64PrimeExponentP,
                                       String base64PrimeExponentQ,
                                       String base64CrtCoefficient)
获取私钥

参数:
base64Modulus - the modulus n
base64PublicExponent - the public exponent e
base64PrivateExponent - the private exponent d
base64PrimeP - the prime factor p of n
base64PrimeQ - the prime factor q of n
base64PrimeExponentP - this is d mod (p-1)
base64PrimeExponentQ - this is d mod (q-1)
base64CrtCoefficient - the Chinese Remainder Theorem coefficient q-1 mod p
返回:

getPrivateKeyFromDotNetRSAParameters

public static PrivateKey getPrivateKeyFromDotNetRSAParameters(String dotnetRsaParameters)
根据 .NET 的私钥字符串,获取对应的私钥实例对象

参数:
dotnetRsaParameters - .NET 平台 RSAParameters 相对应的 XML,格式为:
 
 <RSAKeyValue>
   <Modulus>n -> modulus</Modulus>
   <Exponent>e,公钥指数 -> publicExponent</Exponent>
   <P>p -> prime1</P>
   <Q>q -> prime2</Q>
   <DP>d mod (p - 1) -> exponent1</DP>
   <DQ>d mod (q - 1) -> exponent2</DQ>
   <InverseQ>(InverseQ)(q) = 1 mod p -> coefficient</InverseQ>
   <D>d,私钥指数 -> privateExponent</D>
 </RSAKeyValue>
 
 
返回:
么钥实例

getDotNetRSAParametersWithPrivateKey

public static String getDotNetRSAParametersWithPrivateKey(PrivateKey privateKey)
Returns XML encoded RSA private key string suitable for .NET:CryptoServiceProvider.FromXmlString(true)。 Leading zero bytes (most significant) must be removed for XML encoding for .NET; otherwise format error

参数:
privateKey - 私钥
返回:

getPublicKey

public static PublicKey getPublicKey(String publicKeyStr)
根据公钥字符串,获取对应的公钥实例对象

参数:
publicKeyStr - 经过 BASE64 编码后的公钥字符串

getPublicKey

public static PublicKey getPublicKey(String base64Modulus,
                                     String base64PublicExponent)
根据公钥 n、e 生成公钥

参数:
base64Modulus - 经过 BASE64 编码的公钥 n 串
base64PublicExponent - 经过 BASE64 编码的公钥 e 串
返回:
公钥实例

getPublicKey

public static PublicKey getPublicKey(RSAPublicKeySpec publicKeySpec)
获取公钥

参数:
publicKeySpec -
返回:

getPublicKeyFromDotNetRSAParameters

public static PublicKey getPublicKeyFromDotNetRSAParameters(String dotnetRsaParameters)
根据 .NET 的私钥字符串,获取对应的私钥实例对象

参数:
dotnetRsaParameters - .NET 平台 RSAParameters 相对应的 XML,格式为:
 
 <RSAKeyValue>
     <Modulus>经过 BASE64 编码后的 Modulus</Modulus>
     <Exponent>经过 BASE64 编码后的 Exponent</Exponent>
 </RSAKeyValue>
 
 
返回:

getDotNetRSAParametersWithPublicKey

public static String getDotNetRSAParametersWithPublicKey(PrivateKey privateKey)
Returns XML encoded RSA public key string suitable for .NET:CryptoServiceProvider.FromXmlString(true) Leading zero bytes (most significant) must be removed for XML encoding for .NET; otherwise format error

参数:
privateCrtKey -
返回:
返回结果的格式:

 <RSAKeyValue>
     <Modulus>经过 BASE64 编码后的 Modulus</Modulus>
     <Exponent>经过 BASE64 编码后的 Exponent</Exponent>
 </RSAKeyValue>
 

getRSAPublicKeyAsNetFormat

public static String getRSAPublicKeyAsNetFormat(RSAPublicKey publicKey)
Gets the RSA Public Key. The key idea is to make the key readable for .Net platform.

参数:
publicKey - RSAPublicKey
返回:
String the public key that .Net platform can read. return format is:

 modules : xxx
 exponent : xxx
 

encrypt

public static byte[] encrypt(byte[] data,
                             Key key)
对数据进行加密

参数:
data - 要进行加密的明文数据
key - 密钥
返回:
加密后的密文

encrypt

public static byte[] encrypt(byte[] data,
                             Key key,
                             String transformation)
对数据进行加密

参数:
data - 要进行加密的明文数据
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encrypt

public static byte[] encrypt(String data,
                             Key key)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
key - 密钥
返回:
加密后的密文

encrypt

public static byte[] encrypt(String data,
                             Key key,
                             String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encrypt

public static byte[] encrypt(File file,
                             Key key)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encrypt(File, File, Key)

encrypt

public static byte[] encrypt(File file,
                             Key key,
                             String transformation)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encrypt(File, File, Key, String)

encrypt

public static void encrypt(File src,
                           File dest,
                           Key key)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
key - 密钥

encrypt

public static void encrypt(File src,
                           File dest,
                           Key key,
                           String transformation)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

encrypt

public static byte[] encrypt(byte[] data,
                             KeySpec keySpec)
对数据进行加密

参数:
data - 要进行加密的明文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
加密后的密文

encrypt

public static byte[] encrypt(byte[] data,
                             KeySpec keySpec,
                             String transformation)
对数据进行加密

参数:
data - 要进行加密的明文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encrypt

public static byte[] encrypt(String data,
                             KeySpec keySpec)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
加密后的密文

encrypt

public static byte[] encrypt(String data,
                             KeySpec keySpec,
                             String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encrypt

public static byte[] encrypt(File file,
                             KeySpec keySpec)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
#encrypt(File, File, String)

encrypt

public static byte[] encrypt(File file,
                             KeySpec keySpec,
                             String transformation)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
#encrypt(File, File, String, String)

encrypt

public static void encrypt(File src,
                           File dest,
                           KeySpec keySpec)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec

encrypt

public static void encrypt(File src,
                           File dest,
                           KeySpec keySpec,
                           String transformation)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

encryptByPrivateKey

public static byte[] encryptByPrivateKey(byte[] data,
                                         String privateKey)
使用私钥对数据进行加密

参数:
data - 要进行加密的明文数据
privateKey - 私钥
返回:
加密后的密文

encryptByPrivateKey

public static byte[] encryptByPrivateKey(byte[] data,
                                         String privateKey,
                                         String transformation)
使用私钥对数据进行加密

参数:
data - 要进行加密的明文数据
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptByPrivateKey

public static byte[] encryptByPrivateKey(String data,
                                         String privateKey)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
privateKey - 私钥
返回:
加密后的密文

encryptByPrivateKey

public static byte[] encryptByPrivateKey(String data,
                                         String privateKey,
                                         String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptByPrivateKey

public static byte[] encryptByPrivateKey(File file,
                                         String privateKey)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encryptByPrivateKey(File, File, String)

encryptByPrivateKey

public static byte[] encryptByPrivateKey(File file,
                                         String privateKey,
                                         String transformation)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encryptByPrivateKey(File, File, String, String)

encryptByPrivateKey

public static void encryptByPrivateKey(File src,
                                       File dest,
                                       String privateKey)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
privateKey - 私钥

encryptByPrivateKey

public static void encryptByPrivateKey(File src,
                                       File dest,
                                       String privateKey,
                                       String transformation)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

encryptByPublicKey

public static byte[] encryptByPublicKey(byte[] data,
                                        String publicKey)
使用公钥对数据进行加密

参数:
data - 要进行加密的明文数据
publicKey - 公钥
返回:
加密后的密文

encryptByPublicKey

public static byte[] encryptByPublicKey(byte[] data,
                                        String publicKey,
                                        String transformation)
使用公钥对数据进行加密

参数:
data - 要进行加密的明文数据
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptByPublicKey

public static byte[] encryptByPublicKey(String data,
                                        String publicKey)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
publicKey - 公钥
返回:
加密后的密文

encryptByPublicKey

public static byte[] encryptByPublicKey(String data,
                                        String publicKey,
                                        String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptByPublicKey

public static byte[] encryptByPublicKey(File file,
                                        String publicKey)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encryptByPublicKey(File, File, String)

encryptByPublicKey

public static byte[] encryptByPublicKey(File file,
                                        String publicKey,
                                        String transformation)
对文件内容进行加密,文件太大可能会导致内存溢出

参数:
data - 要进行加密的文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文
另请参见:
encryptByPublicKey(File, File, String, String)

encryptByPublicKey

public static void encryptByPublicKey(File src,
                                      File dest,
                                      String publicKey)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
publicKey - 公钥

encryptByPublicKey

public static void encryptByPublicKey(File src,
                                      File dest,
                                      String publicKey,
                                      String transformation)
对文件进行加密

参数:
src - 源文件
dest - 加密后文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

encryptBase64

public static String encryptBase64(byte[] data,
                                   Key key)
对数据进行加密

参数:
data - 要进行加密的明文数据
key - 密钥
返回:
加密后的密文

encryptBase64

public static String encryptBase64(byte[] data,
                                   Key key,
                                   String transformation)
对数据进行加密

参数:
data - 要进行加密的明文数据
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64

public static String encryptBase64(String data,
                                   Key key)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
key - 密钥
返回:
加密后的密文

encryptBase64

public static String encryptBase64(String data,
                                   Key key,
                                   String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64

public static String encryptBase64(byte[] data,
                                   KeySpec keySpec)
对数据进行加密

参数:
data - 要进行加密的明文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
加密后的密文

encryptBase64

public static String encryptBase64(byte[] data,
                                   KeySpec keySpec,
                                   String transformation)
对数据进行加密

参数:
data - 要进行加密的明文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64

public static String encryptBase64(String data,
                                   KeySpec keySpec)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
加密后的密文

encryptBase64

public static String encryptBase64(String data,
                                   KeySpec keySpec,
                                   String transformation)
对字符串进行加密

参数:
data - 要进行加密的明文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64ByPrivateKey

public static String encryptBase64ByPrivateKey(byte[] data,
                                               String privateKey)
使用私钥对数据进行加密

参数:
data - 要进行加密的明文数据
privateKey - 私钥
返回:
加密后的密文

encryptBase64ByPrivateKey

public static String encryptBase64ByPrivateKey(byte[] data,
                                               String privateKey,
                                               String transformation)
使用私钥对数据进行加密

参数:
data - 要进行加密的明文数据
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64ByPrivateKey

public static String encryptBase64ByPrivateKey(String data,
                                               String privateKey)
使用私钥对字符串进行加密

参数:
data - 要进行加密的明文字符串
privateKey - 私钥
返回:
加密后的密文

encryptBase64ByPrivateKey

public static String encryptBase64ByPrivateKey(String data,
                                               String privateKey,
                                               String transformation)
使用私钥对字符串进行加密

参数:
data - 要进行加密的明文字符串
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64ByPublicKey

public static String encryptBase64ByPublicKey(byte[] data,
                                              String publicKey)
使用公钥对数据进行加密

参数:
data - 要进行加密的明文数据
publicKey - 公钥
返回:
加密后的密文

encryptBase64ByPublicKey

public static String encryptBase64ByPublicKey(byte[] data,
                                              String publicKey,
                                              String transformation)
使用公钥对数据进行加密

参数:
data - 要进行加密的明文数据
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

encryptBase64ByPublicKey

public static String encryptBase64ByPublicKey(String data,
                                              String publicKey)
使用公钥对字符串进行加密

参数:
data - 要进行加密的明文字符串
publicKey - 公钥
返回:
加密后的密文

encryptBase64ByPublicKey

public static String encryptBase64ByPublicKey(String data,
                                              String publicKey,
                                              String transformation)
使用公钥对字符串进行加密

参数:
data - 要进行加密的明文字符串
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
加密后的密文

decrypt

public static byte[] decrypt(byte[] data,
                             Key key)
对数据进行解密

参数:
data - 要进行解密的密文数据
key - 密钥
返回:
解密后的密文

decrypt

public static byte[] decrypt(byte[] encryptedData,
                             Key key,
                             String transformation)
对数据进行解密

参数:
data - 要进行解密的密文
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的明文

decrypt

public static byte[] decrypt(String data,
                             Key key)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
key - 密钥
返回:
解密后的密文

decrypt

public static byte[] decrypt(String data,
                             Key key,
                             String transformation)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decrypt

public static byte[] decrypt(File file,
                             Key key)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decrypt(File, File, Key)

decrypt

public static byte[] decrypt(File file,
                             Key key,
                             String transformation)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decrypt(File, File, Key, String)

decrypt

public static void decrypt(File src,
                           File dest,
                           Key key)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
key - 密钥

decrypt

public static void decrypt(File src,
                           File dest,
                           Key key,
                           String transformation)
对文件进行解密

参数:
src - 加密后的文件
dest - 解密后的文件
key - 密钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

decrypt

public static byte[] decrypt(byte[] data,
                             KeySpec keySpec)
对数据进行解密

参数:
data - 要进行解密的密文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
解密后的密文

decrypt

public static byte[] decrypt(byte[] data,
                             KeySpec keySpec,
                             String transformation)
对数据进行解密

参数:
data - 要进行解密的密文数据
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decrypt

public static byte[] decrypt(String data,
                             KeySpec keySpec)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
返回:
解密后的密文

decrypt

public static byte[] decrypt(String data,
                             KeySpec keySpec,
                             String transformation)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decrypt

public static byte[] decrypt(File file,
                             KeySpec keySpec)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
#decrypt(File, File, String)

decrypt

public static byte[] decrypt(File file,
                             KeySpec keySpec,
                             String transformation)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
#decrypt(File, File, String, String)

decrypt

public static void decrypt(File src,
                           File dest,
                           KeySpec keySpec)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec

decrypt

public static void decrypt(File src,
                           File dest,
                           KeySpec keySpec,
                           String transformation)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
keySpec - RSA 专用密钥规范,类型必须是 RSAPrivateKeySpecRSAPublicKeySpec
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

decryptByPrivateKey

public static byte[] decryptByPrivateKey(byte[] data,
                                         String privateKey)
使用私钥对数据进行解密

参数:
data - 要进行解密的密文数据
privateKey - 私钥
返回:
解密后的密文

decryptByPrivateKey

public static byte[] decryptByPrivateKey(byte[] data,
                                         String privateKey,
                                         String transformation)
使用私钥对数据进行解密

参数:
data - 要进行解密的密文数据
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decryptByPrivateKey

public static byte[] decryptByPrivateKey(String data,
                                         String privateKey)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
privateKey - 私钥
返回:
解密后的密文

decryptByPrivateKey

public static byte[] decryptByPrivateKey(String data,
                                         String privateKey,
                                         String transformation)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decryptByPrivateKey

public static byte[] decryptByPrivateKey(File file,
                                         String privateKey)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decryptByPrivateKey(File, File, String)

decryptByPrivateKey

public static byte[] decryptByPrivateKey(File file,
                                         String privateKey,
                                         String transformation)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decryptByPrivateKey(File, File, String, String)

decryptByPrivateKey

public static void decryptByPrivateKey(File src,
                                       File dest,
                                       String privateKey)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
privateKey - 私钥

decryptByPrivateKey

public static void decryptByPrivateKey(File src,
                                       File dest,
                                       String privateKey,
                                       String transformation)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
privateKey - 私钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.

decryptByPublicKey

public static byte[] decryptByPublicKey(byte[] data,
                                        String publicKey)
使用公钥对数据进行解密

参数:
data - 要进行解密的密文数据
publicKey - 公钥
返回:
解密后的密文

decryptByPublicKey

public static byte[] decryptByPublicKey(byte[] data,
                                        String publicKey,
                                        String transformation)
使用公钥对数据进行解密

参数:
data - 要进行解密的密文数据
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decryptByPublicKey

public static byte[] decryptByPublicKey(String data,
                                        String publicKey)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
publicKey - 公钥
返回:
解密后的密文

decryptByPublicKey

public static byte[] decryptByPublicKey(String data,
                                        String publicKey,
                                        String transformation)
对字符串进行解密

参数:
data - 经过 BASE64 编码的的密文字符串
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文

decryptByPublicKey

public static byte[] decryptByPublicKey(File file,
                                        String publicKey)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decryptByPublicKey(File, File, String)

decryptByPublicKey

public static byte[] decryptByPublicKey(File file,
                                        String publicKey,
                                        String transformation)
对文件内容进行解密,文件太大可能会导致内存溢出

参数:
data - 要进行解密的文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.
返回:
解密后的密文
另请参见:
decryptByPublicKey(File, File, String, String)

decryptByPublicKey

public static void decryptByPublicKey(File src,
                                      File dest,
                                      String publicKey)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
publicKey - 公钥

decryptByPublicKey

public static void decryptByPublicKey(File src,
                                      File dest,
                                      String publicKey,
                                      String transformation)
对文件进行解密

参数:
src - 源文件
dest - 解密后文件
publicKey - 公钥
transformation - the name of the transformation, format is "Algorithm/Modes/Paddings", e.g., DES/CBC/PKCS5Padding. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard transformation names.


Copyright © 2014 广联达软件股份有限公司(Glodon Software Co., Ltd.). All rights reserved.