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


Java Strings.fromByteArray方法代码示例

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


在下文中一共展示了Strings.fromByteArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:thedrummeraki,项目名称:Aki-SSL,代码行数:30,代码来源:DANEEntrySelectorFactory.java

示例2: getTime

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * return the time - always in the form of 
 *  YYYYMMDDhhmmssGMT(+hh:mm|-hh:mm).
 * <p>
 * Normally in a certificate we would expect "Z" rather than "GMT",
 * however adding the "GMT" means we can just use:
 * <pre>
 *     dateF = new SimpleDateFormat("yyyyMMddHHmmssz");
 * </pre>
 * To read in the time and get a date which is compatible with our local
 * time zone.
 */
public String getTime()
{
    String stime = Strings.fromByteArray(time);

    //
    // standardise the format.
    //             
    if (stime.charAt(stime.length() - 1) == 'Z')
    {
        return stime.substring(0, stime.length() - 1) + "GMT+00:00";
    }
    else
    {
        int signPos = stime.length() - 5;
        char sign = stime.charAt(signPos);
        if (sign == '-' || sign == '+')
        {
            return stime.substring(0, signPos)
                + "GMT"
                + stime.substring(signPos, signPos + 3)
                + ":"
                + stime.substring(signPos + 3);
        }
        else
        {
            signPos = stime.length() - 3;
            sign = stime.charAt(signPos);
            if (sign == '-' || sign == '+')
            {
                return stime.substring(0, signPos)
                    + "GMT"
                    + stime.substring(signPos)
                    + ":00";
            }
        }
    }            
    return stime + calculateGMTOffset();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:51,代码来源:DERGeneralizedTime.java

示例3: toBase64String

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public static String toBase64String(
    byte[] data,
    int    off,
    int    length)
{
    byte[] encoded = encode(data, off, length);
    return Strings.fromByteArray(encoded);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:Base64.java

示例4: toHexString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public static String toHexString(
    byte[] data,
    int    off,
    int    length)
{
    byte[] encoded = encode(data, off, length);
    return Strings.fromByteArray(encoded);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:Hex.java

示例5: getString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String getString() 
{
    return Strings.fromByteArray(string);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DERGeneralString.java

示例6: getTimeString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Return the time.
 * @return The time string as it appeared in the encoded object.
 */
public String getTimeString()
{
    return Strings.fromByteArray(time);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:DERGeneralizedTime.java

示例7: getTime

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * return the time - always in the form of 
 *  YYMMDDhhmmssGMT(+hh:mm|-hh:mm).
 * <p>
 * Normally in a certificate we would expect "Z" rather than "GMT",
 * however adding the "GMT" means we can just use:
 * <pre>
 *     dateF = new SimpleDateFormat("yyMMddHHmmssz");
 * </pre>
 * To read in the time and get a date which is compatible with our local
 * time zone.
 * <p>
 * <b>Note:</b> In some cases, due to the local date processing, this
 * may lead to unexpected results. If you want to stick the normal
 * convention of 1950 to 2049 use the getAdjustedTime() method.
 */
public String getTime()
{
    String stime = Strings.fromByteArray(time);

    //
    // standardise the format.
    //
    if (stime.indexOf('-') < 0 && stime.indexOf('+') < 0)
    {
        if (stime.length() == 11)
        {
            return stime.substring(0, 10) + "00GMT+00:00";
        }
        else
        {
            return stime.substring(0, 12) + "GMT+00:00";
        }
    }
    else
    {
        int index = stime.indexOf('-');
        if (index < 0)
        {
            index = stime.indexOf('+');
        }
        String d = stime;

        if (index == stime.length() - 3)
        {
            d += "00";
        }

        if (index == 10)
        {
            return d.substring(0, 10) + "00GMT" + d.substring(10, 13) + ":" + d.substring(13, 15);
        }
        else
        {
            return d.substring(0, 12) + "GMT" + d.substring(12, 15) + ":" +  d.substring(15, 17);
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:59,代码来源:DERUTCTime.java

示例8: toString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String toString() 
{
  return Strings.fromByteArray(time);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DERUTCTime.java

示例9: getString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Decode the encoded string and return it, 8 bit encoding assumed.
 * @return the decoded String
 */
public String getString()
{
    return Strings.fromByteArray(string);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:DERT61String.java

示例10: getString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String getString()
{
    return Strings.fromByteArray(string);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:DERNumericString.java

示例11: encodeData

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
private static String encodeData(
    byte[] data)

{
    if (data.length != 24 && data.length != 16) // 192 bit key or 128 bit salt expected
    {
        throw new DataLengthException("Invalid length: " + data.length + ", 24 for key or 16 for salt expected");
    }
    boolean salt = false;
    if (data.length == 16)//salt
    {
        salt = true;
        byte[] tmp = new byte[18];// zero padding
        System.arraycopy(data, 0, tmp, 0, data.length);
        data = tmp;
    }
    else // key
    {
        data[data.length - 1] = (byte)0;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int len = data.length;

    int a1, a2, a3;
    int i;
    for (i = 0; i < len; i += 3)
    {
        a1 = data[i] & 0xff;
        a2 = data[i + 1] & 0xff;
        a3 = data[i + 2] & 0xff;

        out.write(encodingTable[(a1 >>> 2) & 0x3f]);
        out.write(encodingTable[((a1 << 4) | (a2 >>> 4)) & 0x3f]);
        out.write(encodingTable[((a2 << 2) | (a3 >>> 6)) & 0x3f]);
        out.write(encodingTable[a3 & 0x3f]);
    }

    String result = Strings.fromByteArray(out.toByteArray());
    if (salt == true)// truncate padding
    {
        return result.substring(0, 22);
    }
    else
    {
        return result.substring(0, result.length() - 1);
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:49,代码来源:OpenBSDBCrypt.java

示例12: getString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Return a Java String representation of our contained String.
 *
 * @return a Java String representing our contents.
 */
public String getString() 
{
    return Strings.fromByteArray(string);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:10,代码来源:DERGeneralString.java

示例13: getTimeString

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Return the time.
 *
 * @return The time string as it appeared in the encoded object.
 */
public String getTimeString()
{
    return Strings.fromByteArray(time);
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:10,代码来源:ASN1GeneralizedTime.java

示例14: decode

import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
/**
 * Decode {@code StringName} from an ASN.1 data object.
 *
 * @param type The actual general name type.
 * @param primitive The ASN.1 data object to decode.
 * @return The decoded general name object.
 * @throws IOException if an I/O error occurs during decoding.
 */
public static StringName decode(GeneralNameType type, ASN1Primitive primitive) throws IOException {
	ASN1Primitive object = decodeTagged(primitive, type.value());

	return new StringName(type, Strings.fromByteArray(decodePrimitive(object, ASN1OctetString.class).getOctets()));
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:14,代码来源:StringName.java


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