当前位置: 首页>>代码示例>>Java>>正文


Java PBEParametersGenerator.PKCS5PasswordToUTF8Bytes方法代码示例

本文整理汇总了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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:PBE.java

示例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);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:10,代码来源:PasswordRecipientInformation.java

示例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();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:13,代码来源:BcPasswordRecipientInfoGenerator.java

示例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();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:13,代码来源:BcPasswordRecipient.java

示例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());
        }
    }
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:34,代码来源:BCPBEKey.java

示例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);
}
 
开发者ID:dzhemriza,项目名称:toffi,代码行数:7,代码来源:BcPasswordBasedKey.java


注:本文中的org.bouncycastle.crypto.PBEParametersGenerator.PKCS5PasswordToUTF8Bytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。