gboat2.base.bridge.util.security
类 Encryptor

java.lang.Object
  继承者 gboat2.base.bridge.util.security.Encryptor
直接已知子类:
MD5Util

public class Encryptor
extends Object

从以下版本开始:
3.0
作者:
何明旺

字段摘要
static String MD2
          The MD2 message digest algorithm defined in RFC 1319.
static String MD5
          The MD5 message digest algorithm defined in RFC 1321.
static String SHA
          Secure Hash Algorithm,安全散列算法
static String SHA_1
          The SHA-1 hash algorithm defined in the FIPS PUB 180-2.
static String SHA_256
          The SHA-256 hash algorithm defined in the FIPS PUB 180-2.
static String SHA_384
          The SHA-384 hash algorithm defined in the FIPS PUB 180-2.
static String SHA_512
          The SHA-512 hash algorithm defined in the FIPS PUB 180-2.
 
构造方法摘要
Encryptor()
           
 
方法摘要
static byte[] decrypt(byte[] data, Key key, String transformation)
          对数据进行解密
static byte[] digest(byte[] data, String algorithm)
           
static byte[] digest(File file, String algorithm)
           
static byte[] digest(String data, String algorithm)
           
static byte[] encrypt(byte[] data, Key key, String transformation)
          对数据进行加密
protected static String getAlgorithmFromTransformation(String transformation)
          取得算法名称
static KeyGenerator getKeyGenerator(String algorithm)
          获取密钥生成器实例
static KeyPair getKeyPair(String algorithm, int size)
          根据算法名称和密钥长度生成私钥公钥对
static MessageDigest getMessageDigest(String algorithm)
          获取 MessageDigest 实例
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

MD2

public static final String MD2
The MD2 message digest algorithm defined in RFC 1319.

另请参见:
常量字段值

MD5

public static final String MD5
The MD5 message digest algorithm defined in RFC 1321.

另请参见:
常量字段值

SHA

public static final String SHA
Secure Hash Algorithm,安全散列算法

另请参见:
常量字段值

SHA_1

public static final String SHA_1
The SHA-1 hash algorithm defined in the FIPS PUB 180-2.

另请参见:
常量字段值

SHA_256

public static final String SHA_256
The SHA-256 hash algorithm defined in the FIPS PUB 180-2.

另请参见:
常量字段值

SHA_384

public static final String SHA_384
The SHA-384 hash algorithm defined in the FIPS PUB 180-2.

另请参见:
常量字段值

SHA_512

public static final String SHA_512
The SHA-512 hash algorithm defined in the FIPS PUB 180-2.

另请参见:
常量字段值
构造方法详细信息

Encryptor

public Encryptor()
方法详细信息

getMessageDigest

public static MessageDigest getMessageDigest(String algorithm)
获取 MessageDigest 实例

参数:
algorithm - 加密算法,请参见本类中的名称为 MD*SHA* 的常量
返回:

digest

public static byte[] digest(byte[] data,
                            String algorithm)
参数:
data - 要加密的数据
algorithm - 加密算法,请参见本类中的名称为 MD*SHA* 的常量
返回:
密文

digest

public static byte[] digest(String data,
                            String algorithm)
参数:
data - 要加密的字符串
algorithm - 加密算法,请参见本类中的名称为 MD*SHA* 的常量
返回:
密文

digest

public static byte[] digest(File file,
                            String algorithm)
参数:
file - 要加密的文件
algorithm - 加密算法,请参见本类中的名称为 MD*SHA* 的常量
返回:
密文

getKeyGenerator

public static KeyGenerator getKeyGenerator(String algorithm)
获取密钥生成器实例

参数:
algorithm - 加密算法的名称,支持的算法有: AES、ARCFOUR、Blowfish、DES、DESede、HmacMD5、HmacSHA1、HmacSHA256、HmacSHA384、HmacSHA512、RC2
返回:
密钥生成器

getKeyPair

public static KeyPair getKeyPair(String algorithm,
                                 int size)
根据算法名称和密钥长度生成私钥公钥对

参数:
algorithm - 算法名称,如:RSA、DSA
size - 密钥长度,如:512、1024
返回:

getAlgorithmFromTransformation

protected static String getAlgorithmFromTransformation(String transformation)
取得算法名称

参数:
transformation -
返回:

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.

The following table lists cipher algorithms available in the SunJCE provider

Algorithm Name Modes Paddings
AES ECB, CBC, PCBC, CTR, CTS, CFB, CFB8..CFB128, OFB, OFB8..OFB128 NOPADDING, PKCS5PADDING, ISO10126PADDING
AESWrap ECB NOPADDING
ARCFOUR ECB NOPADDING
Blowfish, DES, DESede, RC2 ECB, CBC, PCBC, CTR, CTS, CFB, CFB8..CFB64, OFB, OFB8..OFB64 NOPADDING, PKCS5PADDING, ISO10126PADDING
DESedeWrap CBC NOPADDING
PBEWithMD5AndDES, PBEWithMD5AndTripleDES, PBEWithSHA1AndDESede, PBEWithSHA1AndRC2_40 CBC PKCS5Padding
RSA ECB NOPADDING, PKCS1PADDING, OAEPWITHMD5ANDMGF1PADDING, OAEPWITHSHA1ANDMGF1PADDING, OAEPWITHSHA-1ANDMGF1PADDING, OAEPWITHSHA-256ANDMGF1PADDING, OAEPWITHSHA-384ANDMGF1PADDING, OAEPWITHSHA-512ANDMGF1PADDING
返回:
密文

decrypt

public static byte[] decrypt(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.

The following table lists cipher algorithms available in the SunJCE provider

Algorithm Name Modes Paddings
AES ECB, CBC, PCBC, CTR, CTS, CFB, CFB8..CFB128, OFB, OFB8..OFB128 NOPADDING, PKCS5PADDING, ISO10126PADDING
AESWrap ECB NOPADDING
ARCFOUR ECB NOPADDING
Blowfish, DES, DESede, RC2 ECB, CBC, PCBC, CTR, CTS, CFB, CFB8..CFB64, OFB, OFB8..OFB64 NOPADDING, PKCS5PADDING, ISO10126PADDING
DESedeWrap CBC NOPADDING
PBEWithMD5AndDES, PBEWithMD5AndTripleDES, PBEWithSHA1AndDESede, PBEWithSHA1AndRC2_40 CBC PKCS5Padding
RSA ECB NOPADDING, PKCS1PADDING, OAEPWITHMD5ANDMGF1PADDING, OAEPWITHSHA1ANDMGF1PADDING, OAEPWITHSHA-1ANDMGF1PADDING, OAEPWITHSHA-256ANDMGF1PADDING, OAEPWITHSHA-384ANDMGF1PADDING, OAEPWITHSHA-512ANDMGF1PADDING
返回:
密文


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