java.securtiy KeyGenerator对象详解

KeyGenerator对象介绍:

keyGenerator对象位于javax.crypto包下

jdk 1.6 doc介绍:KeyGenerator 此类提供(对称加密算法:AES,DES 等等)密钥生成器的功能


获得keyGenerator:

一般是通过此类的静态方法getInstance()方法获得,

此类的全局变量都为私有变量,因此不讨论


方法:

  1. getAlgorithm();获得算法名称
  2. getInstance();通过指定算法,亦可指定提供者来构造KeyGenerator对象,有多个重载方法
  3. getProvider();返回此算法实现的提供商
  4. init(SecureRandom sRandoom);用于初始化KeyGenerator对象,通过随机源的方式
  5. init(int size);通过指定生成秘钥的大小,来初始化的方式
  6. init(AlgorithmParameterSpec params);通过指定参数集来初始化
  7. init(AlgorithmParameterSpec params,SecureRandom sRandoom);通过指定参数集和随机数源的方式生成
  8. init(int arg0, SecureRandom arg1);通过指定大小和随机源的方式产生
  9. generatorKey();生成秘钥 // 返回SecertKey对象

支持的算法有:

AES    
ARCFOUR    
Blowfish    
DES
DESede    
HmacMD5    
HmacSHA1,HmacSHA256,HmacSHA384,HmacSHA512
RC2

猜你喜欢

转载自blog.csdn.net/kzcming/article/details/80095114