本文整理汇总了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);
}
示例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();
}
示例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);
}
示例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);
}
示例5: getString
import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String getString()
{
return Strings.fromByteArray(string);
}
示例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);
}
示例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);
}
}
}
示例8: toString
import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String toString()
{
return Strings.fromByteArray(time);
}
示例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);
}
示例10: getString
import org.bouncycastle.util.Strings; //导入方法依赖的package包/类
public String getString()
{
return Strings.fromByteArray(string);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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()));
}