本文整理汇总了Java中org.bouncycastle.crypto.PBEParametersGenerator.PKCS5PasswordToUTF8Bytes方法的典型用法代码示例。如果您正苦于以下问题:Java PBEParametersGenerator.PKCS5PasswordToUTF8Bytes方法的具体用法?Java PBEParametersGenerator.PKCS5PasswordToUTF8Bytes怎么用?Java PBEParametersGenerator.PKCS5PasswordToUTF8Bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.PBEParametersGenerator
的用法示例。
在下文中一共展示了PBEParametersGenerator.PKCS5PasswordToUTF8Bytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertPassword
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
private static byte[] convertPassword(int type, PBEKeySpec keySpec)
{
byte[] key;
if (type == PKCS12)
{
key = PBEParametersGenerator.PKCS12PasswordToBytes(keySpec.getPassword());
}
else if (type == PKCS5S2_UTF8 || type == PKCS5S1_UTF8)
{
key = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(keySpec.getPassword());
}
else
{
key = PBEParametersGenerator.PKCS5PasswordToBytes(keySpec.getPassword());
}
return key;
}
示例2: getPasswordBytes
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
protected byte[] getPasswordBytes(int scheme, char[] password)
{
if (scheme == PasswordRecipient.PKCS5_SCHEME2)
{
return PBEParametersGenerator.PKCS5PasswordToBytes(password);
}
return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);
}
示例3: calculateDerivedKey
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
protected byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize)
throws CMSException
{
PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters());
byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);
PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator();
gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue());
return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey();
}
示例4: calculateDerivedKey
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public byte[] calculateDerivedKey(int schemeID, AlgorithmIdentifier derivationAlgorithm, int keySize)
throws CMSException
{
PBKDF2Params params = PBKDF2Params.getInstance(derivationAlgorithm.getParameters());
byte[] encodedPassword = (schemeID == PasswordRecipient.PKCS5_SCHEME2) ? PBEParametersGenerator.PKCS5PasswordToBytes(password) : PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);
PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator();
gen.init(encodedPassword, params.getSalt(), params.getIterationCount().intValue());
return ((KeyParameter)gen.generateDerivedParameters(keySize)).getKey();
}
示例5: getEncoded
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public byte[] getEncoded()
{
if (param != null)
{
KeyParameter kParam;
if (param instanceof ParametersWithIV)
{
kParam = (KeyParameter)((ParametersWithIV)param).getParameters();
}
else
{
kParam = (KeyParameter)param;
}
return kParam.getKey();
}
else
{
if (type == PBE.PKCS12)
{
return PBEParametersGenerator.PKCS12PasswordToBytes(pbeKeySpec.getPassword());
}
else if (type == PBE.PKCS5S2_UTF8)
{
return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(pbeKeySpec.getPassword());
}
else
{
return PBEParametersGenerator.PKCS5PasswordToBytes(pbeKeySpec.getPassword());
}
}
}
示例6: BcPasswordBasedKey
import org.bouncycastle.crypto.PBEParametersGenerator; //导入方法依赖的package包/类
public BcPasswordBasedKey(char[] password, int keySize, int iterations, byte[] salt) {
PBEParametersGenerator keyGenerator = new PKCS5S2ParametersGenerator();
byte[] pkcsPasswordBytes = PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password);
keyGenerator.init(pkcsPasswordBytes, salt, iterations);
this.secretKey = (KeyParameter) keyGenerator.generateDerivedParameters(keySize);
}