use of javax.crypto.KeyGenerator in project protools by SeanDragon.
the class ToolIDEA method initKey.
/**
* 生成密钥 <br>
*
* @return byte[] 二进制密钥
*
* @throws Exception
*/
public static byte[] initKey() throws NoSuchAlgorithmException {
// 实例化
KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);
// 初始化
kg.init(128);
// 生成秘密密钥
SecretKey secretKey = kg.generateKey();
// 获得密钥的二进制编码形式
return secretKey.getEncoded();
}
use of javax.crypto.KeyGenerator in project protools by SeanDragon.
the class ToolHmacRipeMD method initHmacRipeMD160Key.
/**
* 初始化HmacRipeMD160密钥
*
* @return byte[] 密钥
*
* @throws Exception
*/
public static byte[] initHmacRipeMD160Key() throws NoSuchAlgorithmException {
// 加入BouncyCastleProvider支持
Security.addProvider(new BouncyCastleProvider());
// 初始化KeyGenerator
KeyGenerator keyGenerator = KeyGenerator.getInstance("HmacRipeMD160");
// 产生秘密密钥
SecretKey secretKey = keyGenerator.generateKey();
// 获得密钥
return secretKey.getEncoded();
}
use of javax.crypto.KeyGenerator in project protools by SeanDragon.
the class ToolAES method initKey.
/**
* 生成密钥 <br>
*
* @return byte[] 二进制密钥
*
* @throws Exception
*/
public static byte[] initKey() throws NoSuchAlgorithmException {
// 实例化
KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM);
/*
* AES 要求密钥长度为 128位、192位或 256位
*/
kg.init(256);
// 生成秘密密钥
SecretKey secretKey = kg.generateKey();
// 获得密钥的二进制编码形式
return secretKey.getEncoded();
}
use of javax.crypto.KeyGenerator in project protools by SeanDragon.
the class ToolMAC method initHmacSHAKey.
/**
* 初始化HmacSHA1密钥
*
* @return
*
* @throws Exception
*/
public static byte[] initHmacSHAKey() throws NoSuchAlgorithmException {
// 初始化KeyGenerator
KeyGenerator keyGenerator = KeyGenerator.getInstance("HMacTiger");
// 产生秘密密钥
SecretKey secretKey = keyGenerator.generateKey();
// 获得密钥
return secretKey.getEncoded();
}
use of javax.crypto.KeyGenerator in project protools by SeanDragon.
the class ToolMAC_BCP method initHmacMD2Key.
/**
* 初始化HmacMD2密钥
*
* @return byte[] 密钥
*
* @throws Exception
*/
public static byte[] initHmacMD2Key() throws NoSuchAlgorithmException {
// 加入BouncyCastleProvider支持
Security.addProvider(new BouncyCastleProvider());
// 初始化KeyGenerator
KeyGenerator keyGenerator = KeyGenerator.getInstance("HmacMD2");
// 产生秘密密钥
SecretKey secretKey = keyGenerator.generateKey();
// 获得密钥
return secretKey.getEncoded();
}
Aggregations