|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Object gboat2.base.bridge.util.security.RSAUtil
public class RSAUtil
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);
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 |
字段详细信息 |
---|
public static final String RSA
public static final String DOTNET_RSA_TRANSFORMATION
构造方法详细信息 |
---|
public RSAUtil()
方法详细信息 |
---|
public static KeyPair getKeyPair()
public static KeyPair getKeyPair(int size)
size
- Key Size [512|1024]public static PrivateKey getPrivateKey(String privateKeyStr)
privateKeyStr
- 经过 BASE64 编码后的私钥字符串
public static PrivateKey getPrivateKey(RSAPrivateKeySpec privateKeySpec)
privateKeySpec
- RSA 专用私钥
public static PrivateKey getPrivateKey(String base64Modulus, String base64PublicExponent, String base64PrivateExponent, String base64PrimeP, String base64PrimeQ, String base64PrimeExponentP, String base64PrimeExponentQ, String base64CrtCoefficient)
base64Modulus
- the modulus nbase64PublicExponent
- the public exponent ebase64PrivateExponent
- the private exponent dbase64PrimeP
- the prime factor p of nbase64PrimeQ
- the prime factor q of nbase64PrimeExponentP
- this is d mod (p-1)base64PrimeExponentQ
- this is d mod (q-1)base64CrtCoefficient
- the Chinese Remainder Theorem coefficient q-1 mod p
public static PrivateKey getPrivateKeyFromDotNetRSAParameters(String dotnetRsaParameters)
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>
public static String getDotNetRSAParametersWithPrivateKey(PrivateKey privateKey)
privateKey
- 私钥
public static PublicKey getPublicKey(String publicKeyStr)
publicKeyStr
- 经过 BASE64 编码后的公钥字符串public static PublicKey getPublicKey(String base64Modulus, String base64PublicExponent)
base64Modulus
- 经过 BASE64 编码的公钥 n 串base64PublicExponent
- 经过 BASE64 编码的公钥 e 串
public static PublicKey getPublicKey(RSAPublicKeySpec publicKeySpec)
publicKeySpec
-
public static PublicKey getPublicKeyFromDotNetRSAParameters(String dotnetRsaParameters)
dotnetRsaParameters
- .NET 平台 RSAParameters 相对应的 XML,格式为:
<RSAKeyValue>
<Modulus>经过 BASE64 编码后的 Modulus</Modulus>
<Exponent>经过 BASE64 编码后的 Exponent</Exponent>
</RSAKeyValue>
public static String getDotNetRSAParametersWithPublicKey(PrivateKey privateKey)
privateCrtKey
-
<RSAKeyValue>
<Modulus>经过 BASE64 编码后的 Modulus</Modulus>
<Exponent>经过 BASE64 编码后的 Exponent</Exponent>
</RSAKeyValue>
public static String getRSAPublicKeyAsNetFormat(RSAPublicKey publicKey)
publicKey
- RSAPublicKey
modules : xxx
exponent : xxx
public static byte[] encrypt(byte[] data, Key key)
data
- 要进行加密的明文数据key
- 密钥
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.
public static byte[] encrypt(String data, Key key)
data
- 要进行加密的明文字符串key
- 密钥
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.
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)
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)
public static void encrypt(File src, File dest, Key key)
src
- 源文件dest
- 加密后文件key
- 密钥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.public static byte[] encrypt(byte[] data, KeySpec keySpec)
data
- 要进行加密的明文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static byte[] encrypt(byte[] data, KeySpec keySpec, String transformation)
data
- 要进行加密的明文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static byte[] encrypt(String data, KeySpec keySpec)
data
- 要进行加密的明文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static byte[] encrypt(String data, KeySpec keySpec, String transformation)
data
- 要进行加密的明文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static byte[] encrypt(File file, KeySpec keySpec)
data
- 要进行加密的文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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)
public static byte[] encrypt(File file, KeySpec keySpec, String transformation)
data
- 要进行加密的文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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)
public static void encrypt(File src, File dest, KeySpec keySpec)
src
- 源文件dest
- 加密后文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static void encrypt(File src, File dest, KeySpec keySpec, String transformation)
src
- 源文件dest
- 加密后文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.public static byte[] encryptByPrivateKey(byte[] data, String privateKey)
data
- 要进行加密的明文数据privateKey
- 私钥
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.
public static byte[] encryptByPrivateKey(String data, String privateKey)
data
- 要进行加密的明文字符串privateKey
- 私钥
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.
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)
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)
public static void encryptByPrivateKey(File src, File dest, String privateKey)
src
- 源文件dest
- 加密后文件privateKey
- 私钥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.public static byte[] encryptByPublicKey(byte[] data, String publicKey)
data
- 要进行加密的明文数据publicKey
- 公钥
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.
public static byte[] encryptByPublicKey(String data, String publicKey)
data
- 要进行加密的明文字符串publicKey
- 公钥
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.
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)
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)
public static void encryptByPublicKey(File src, File dest, String publicKey)
src
- 源文件dest
- 加密后文件publicKey
- 公钥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.public static String encryptBase64(byte[] data, Key key)
data
- 要进行加密的明文数据key
- 密钥
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.
public static String encryptBase64(String data, Key key)
data
- 要进行加密的明文字符串key
- 密钥
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.
public static String encryptBase64(byte[] data, KeySpec keySpec)
data
- 要进行加密的明文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static String encryptBase64(byte[] data, KeySpec keySpec, String transformation)
data
- 要进行加密的明文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static String encryptBase64(String data, KeySpec keySpec)
data
- 要进行加密的明文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static String encryptBase64(String data, KeySpec keySpec, String transformation)
data
- 要进行加密的明文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static String encryptBase64ByPrivateKey(byte[] data, String privateKey)
data
- 要进行加密的明文数据privateKey
- 私钥
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.
public static String encryptBase64ByPrivateKey(String data, String privateKey)
data
- 要进行加密的明文字符串privateKey
- 私钥
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.
public static String encryptBase64ByPublicKey(byte[] data, String publicKey)
data
- 要进行加密的明文数据publicKey
- 公钥
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.
public static String encryptBase64ByPublicKey(String data, String publicKey)
data
- 要进行加密的明文字符串publicKey
- 公钥
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.
public static byte[] decrypt(byte[] data, Key key)
data
- 要进行解密的密文数据key
- 密钥
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.
public static byte[] decrypt(String data, Key key)
data
- 经过 BASE64 编码的的密文字符串key
- 密钥
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.
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)
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)
public static void decrypt(File src, File dest, Key key)
src
- 源文件dest
- 解密后文件key
- 密钥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.public static byte[] decrypt(byte[] data, KeySpec keySpec)
data
- 要进行解密的密文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static byte[] decrypt(byte[] data, KeySpec keySpec, String transformation)
data
- 要进行解密的密文数据keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static byte[] decrypt(String data, KeySpec keySpec)
data
- 经过 BASE64 编码的的密文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static byte[] decrypt(String data, KeySpec keySpec, String transformation)
data
- 经过 BASE64 编码的的密文字符串keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.
public static byte[] decrypt(File file, KeySpec keySpec)
data
- 要进行解密的文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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)
public static byte[] decrypt(File file, KeySpec keySpec, String transformation)
data
- 要进行解密的文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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)
public static void decrypt(File src, File dest, KeySpec keySpec)
src
- 源文件dest
- 解密后文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
public static void decrypt(File src, File dest, KeySpec keySpec, String transformation)
src
- 源文件dest
- 解密后文件keySpec
- RSA 专用密钥规范,类型必须是 RSAPrivateKeySpec
或 RSAPublicKeySpec
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.public static byte[] decryptByPrivateKey(byte[] data, String privateKey)
data
- 要进行解密的密文数据privateKey
- 私钥
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.
public static byte[] decryptByPrivateKey(String data, String privateKey)
data
- 经过 BASE64 编码的的密文字符串privateKey
- 私钥
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.
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)
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)
public static void decryptByPrivateKey(File src, File dest, String privateKey)
src
- 源文件dest
- 解密后文件privateKey
- 私钥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.public static byte[] decryptByPublicKey(byte[] data, String publicKey)
data
- 要进行解密的密文数据publicKey
- 公钥
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.
public static byte[] decryptByPublicKey(String data, String publicKey)
data
- 经过 BASE64 编码的的密文字符串publicKey
- 公钥
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.
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)
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)
public static void decryptByPublicKey(File src, File dest, String publicKey)
src
- 源文件dest
- 解密后文件publicKey
- 公钥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.
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |