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


Java Strings.toUTF8ByteArray方法代码示例

本文整理汇总了Java中org.bouncycastle.util.Strings.toUTF8ByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.toUTF8ByteArray方法的具体用法?Java Strings.toUTF8ByteArray怎么用?Java Strings.toUTF8ByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.util.Strings的用法示例。


在下文中一共展示了Strings.toUTF8ByteArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSelector

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Create a selector for the passed in email address.
 * @param emailAddress the emails address of interest.
 * @throws DANEException in case of issue generating a matching name.
 */
public DANEEntrySelector createSelector(String emailAddress)
    throws DANEException
{
    final byte[] enc = Strings.toUTF8ByteArray(emailAddress.substring(0, emailAddress.indexOf('@')));

    try
    {
        OutputStream cOut = digestCalculator.getOutputStream();

        cOut.write(enc);

        cOut.close();
    }
    catch (IOException e)
    {
        throw new DANEException("Unable to calculate digest string: " + e.getMessage(), e);
    }

    byte[] hash = digestCalculator.getDigest();

    final String domainName = Strings.fromByteArray(Hex.encode(hash)) + "._smimecert." + emailAddress.substring(emailAddress.indexOf('@') + 1);

    return new DANEEntrySelector(domainName);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:30,代码来源:DANEEntrySelectorFactory.java

示例2: updateDigestIncludingSize

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static void updateDigestIncludingSize(Digest digest, String string)
{
    byte[] byteArray = Strings.toUTF8ByteArray(string);
    digest.update(intToByteArray(byteArray.length), 0, 4);
    digest.update(byteArray, 0, byteArray.length);
    Arrays.fill(byteArray, (byte)0);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:JPAKEUtil.java

示例3: PKCS5PasswordToUTF8Bytes

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * converts a password to a byte array according to the scheme in
 * PKCS5 (UTF-8, no padding)
 *
 * @param password a character array representing the password.
 * @return a byte array representing the password.
 */
public static byte[] PKCS5PasswordToUTF8Bytes(
    char[]  password)
{
    if (password != null)
    {
        return Strings.toUTF8ByteArray(password);
    }
    else
    {
        return new byte[0];
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:PBEParametersGenerator.java

示例4: createData

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static byte[] createData(byte reason, String description)
{
    byte[] descriptionBytes = Strings.toUTF8ByteArray(description);
    byte[] data = new byte[1 + descriptionBytes.length];

    data[0] = reason;
    System.arraycopy(descriptionBytes, 0, data, 1, descriptionBytes.length);

    return data;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:11,代码来源:RevocationReason.java

示例5: genCalculator

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private MacCalculator genCalculator(final PBMParameter params, char[] password)
    throws CRMFException
{
    // From RFC 4211
    //
    //   1.  Generate a random salt value S
    //
    //   2.  Append the salt to the pw.  K = pw || salt.
    //
    //   3.  Hash the value of K.  K = HASH(K)
    //
    //   4.  Iter = Iter - 1.  If Iter is greater than zero.  Goto step 3.
    //
    //   5.  Compute an HMAC as documented in [HMAC].
    //
    //       MAC = HASH( K XOR opad, HASH( K XOR ipad, data) )
    //
    //       Where opad and ipad are defined in [HMAC].
    byte[] pw = Strings.toUTF8ByteArray(password);
    byte[] salt = params.getSalt().getOctets();
    byte[] K = new byte[pw.length + salt.length];

    System.arraycopy(pw, 0, K, 0, pw.length);
    System.arraycopy(salt, 0, K, pw.length, salt.length);

    calculator.setup(params.getOwf(), params.getMac());

    int iter = params.getIterationCount().getValue().intValue();
    do
    {
        K = calculator.calculateDigest(K);
    }
    while (--iter > 0);

    final byte[] key = K;

    return new MacCalculator()
    {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();

        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return new AlgorithmIdentifier(CMPObjectIdentifiers.passwordBasedMac, params);
        }

        public GenericKey getKey()
        {
            return new GenericKey(getAlgorithmIdentifier(), key);
        }

        public OutputStream getOutputStream()
        {
            return bOut;
        }

        public byte[] getMac()
        {
            try
            {
                return calculator.calculateMac(key, bOut.toByteArray());
            }
            catch (CRMFException e)
            {
                throw new RuntimeOperatorException("exception calculating mac: " + e.getMessage(), e);
            }
        }
    };
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:69,代码来源:PKMACBuilder.java

示例6: calculateS

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Converts the given password to a {@link BigInteger}
 * for use in arithmetic calculations.
 */
public static BigInteger calculateS(char[] password)
{
    return new BigInteger(Strings.toUTF8ByteArray(password));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:JPAKEUtil.java

示例7: updateDigest

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static void updateDigest(Digest digest, String string)
{
    byte[] byteArray = Strings.toUTF8ByteArray(string);
    digest.update(byteArray, 0, byteArray.length);
    Arrays.fill(byteArray, (byte)0);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JPAKEUtil.java

示例8: updateMac

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static void updateMac(Mac mac, String string)
{
    byte[] byteArray = Strings.toUTF8ByteArray(string);
    mac.update(byteArray, 0, byteArray.length);
    Arrays.fill(byteArray, (byte)0);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JPAKEUtil.java

示例9: DERT61UTF8String

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * basic constructor - with string UTF8 conversion assumed.
 */
public DERT61UTF8String(
    String string)
{
    this(Strings.toUTF8ByteArray(string));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:DERT61UTF8String.java

示例10: DERUTF8String

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * basic constructor
 */
public DERUTF8String(String string)
{
    this.string = Strings.toUTF8ByteArray(string);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:DERUTF8String.java

示例11: generate

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Creates a 60 character Bcrypt String, including
 * version, cost factor, salt and hash, separated by '$'
 *
 * @param cost     the cost factor, treated as an exponent of 2
 * @param salt     a 16 byte salt
 * @param password the password
 * @return a 60 character Bcrypt String
 */
public static String generate(
    char[] password,
    byte[] salt,
    int cost)
{
    if (password == null)
    {
        throw new IllegalArgumentException("Password required.");
    }
    if (salt == null)
    {
        throw new IllegalArgumentException("Salt required.");
    }
    else if (salt.length != 16)
    {
        throw new DataLengthException("16 byte salt required: " + salt.length);
    }
    if (cost < 4 || cost > 31) // Minimum rounds: 16, maximum 2^31
    {
        throw new IllegalArgumentException("Invalid cost factor.");
    }

    byte[] psw = Strings.toUTF8ByteArray(password);

    // 0 termination:

    byte[] tmp = new byte[psw.length >= 72 ? 72 : psw.length + 1];

    if (tmp.length > psw.length)
    {
        System.arraycopy(psw, 0, tmp, 0, psw.length);
    }
    else
    {
        System.arraycopy(psw, 0, tmp, 0, tmp.length);
    }

    Arrays.fill(psw, (byte)0);

    String rv = createBcryptString(tmp, salt, cost);

    Arrays.fill(tmp, (byte)0);

    return rv;
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:55,代码来源:OpenBSDBCrypt.java

示例12: createData

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static byte[] createData(boolean humanReadable, String notationName, String notationValue)
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();

//        (4 octets of flags, 2 octets of name length (M),
//        2 octets of value length (N),
//        M octets of name data,
//        N octets of value data)

        // flags
        out.write(humanReadable ? 0x80 : 0x00);
        out.write(0x0);
        out.write(0x0);
        out.write(0x0);

        byte[] nameData, valueData = null;
        int nameLength, valueLength;

        nameData = Strings.toUTF8ByteArray(notationName);
        nameLength = Math.min(nameData.length, 0xFFFF);

        if (nameLength != nameData.length)
        {
            throw new IllegalArgumentException("notationName exceeds maximum length.");
        }

        valueData = Strings.toUTF8ByteArray(notationValue);
        valueLength = Math.min(valueData.length, 0xFFFF);
        if (valueLength != valueData.length)
        {
            throw new IllegalArgumentException("notationValue exceeds maximum length.");
        }

        // name length
        out.write((nameLength >>> 8) & 0xFF);
        out.write((nameLength >>> 0) & 0xFF);

        // value length
        out.write((valueLength >>> 8) & 0xFF);
        out.write((valueLength >>> 0) & 0xFF);

        // name
        out.write(nameData, 0, nameLength);

        // value
        out.write(valueData, 0, valueLength);

        return out.toByteArray();
    }
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:50,代码来源:NotationData.java

示例13: SignerUserID

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public SignerUserID(
    boolean    critical,
    String     userID)
{
    super(SignatureSubpacketTags.SIGNER_USER_ID, critical, false, Strings.toUTF8ByteArray(userID));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:7,代码来源:SignerUserID.java

示例14: BasicTlsPSKIdentity

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public BasicTlsPSKIdentity(String identity, byte[] psk)
{
    this.identity = Strings.toUTF8ByteArray(identity);
    this.psk = Arrays.clone(psk);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:6,代码来源:BasicTlsPSKIdentity.java

示例15: PKCS5PasswordToUTF8Bytes

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * converts a password to a byte array according to the scheme in
 * PKCS5 (UTF-8, no padding)
 *
 * @param password a character array reqpresenting the password.
 * @return a byte array representing the password.
 */
public static byte[] PKCS5PasswordToUTF8Bytes(
    char[]  password)
{
    return Strings.toUTF8ByteArray(password);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:13,代码来源:PBEParametersGenerator.java


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