org.xipki.util.Hex.encode()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.xipki.util.Hex.encode()方法的一些代码示例,展示了Hex.encode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hex.encode()方法的具体详情如下:
包路径:org.xipki.util.Hex
类名称:Hex
方法名:encode

Hex.encode介绍

暂无

代码示例

代码示例来源:origin: org.xipki/security

/**
 * Returns the hex representation of the bytes.
 *
 * @param bytes
 *          Data to be encoded. Must not be {@code null}.
 * @return the hex representation of the bytes.
 */
protected static String hex(byte[] bytes) {
 return Hex.encode(bytes);
}

代码示例来源:origin: org.xipki/security-pkcs11

/**
 * Returns the hex representation of the bytes.
 *
 * @param bytes
 *          Data to be encoded. Must not be {@code null}.
 * @return the hex representation of the bytes.
 */
protected static String hex(byte[] bytes) {
 return Hex.encode(bytes);
}

代码示例来源:origin: org.xipki/util

/**
 * Formats certificate serial number.
 * @param serialNumber certificate serial number
 * @return formatted certificate serial number
 */
public static String formatCsn(BigInteger serialNumber) {
 return "0x" + Hex.encode(serialNumber.toByteArray());
}

代码示例来源:origin: xipki/xipki

/**
 * Formats certificate serial number.
 * @param serialNumber certificate serial number
 * @return formatted certificate serial number
 */
public static String formatCsn(BigInteger serialNumber) {
 return "0x" + Hex.encode(serialNumber.toByteArray());
}

代码示例来源:origin: org.xipki.shells/shell-base

private static String randomHex(int numOfBytes) {
 SecureRandom random = new SecureRandom();
 byte[] bytes = new byte[numOfBytes];
 random.nextBytes(bytes);
 return Hex.encode(bytes);
}

代码示例来源:origin: org.xipki/ocsp-client

private static String buildMessage(byte[] expected, byte[] is) {
 return StringUtil.concat("nonce unmatch (received ",
   (is == null || is.length == 0 ? "none" : Hex.encode(is)), ", but expected ",
   (expected == null || expected.length == 0 ? "none" : Hex.encode(expected)), ")");
}

代码示例来源:origin: org.xipki.shell/shell-base

private static String randomHex(int numOfBytes) {
 SecureRandom random = new SecureRandom();
 byte[] bytes = new byte[numOfBytes];
 random.nextBytes(bytes);
 return Hex.encode(bytes);
}

代码示例来源:origin: org.xipki/security

public static String hexSha1(byte[] data) {
 return Hex.encode(hash(HashAlgo.SHA1, data, 0, data.length));
}

代码示例来源:origin: org.xipki/security

public static String hexSha256(byte[] data) {
 return Hex.encode(hash(HashAlgo.SHA256, data, 0, data.length));
}

代码示例来源:origin: org.xipki/security

public static String hexSha256(byte[] data, int offset, int len) {
 return Hex.encode(hash(HashAlgo.SHA256, data, offset, len));
}

代码示例来源:origin: org.xipki/security

public static String hexSha1(byte[] data, int offset, int len) {
 return Hex.encode(hash(HashAlgo.SHA1, data, offset, len));
}

代码示例来源:origin: org.xipki/security

public static String hexHash(HashAlgo hashAlgo, byte[] data) {
 return Hex.encode(hash(hashAlgo, data, 0, data.length));
}

代码示例来源:origin: org.xipki/security

public static String hexHash(HashAlgo hashAlgo, byte[] data, int offset, int len) {
 return Hex.encode(hash(hashAlgo, data, offset, len));
}

代码示例来源:origin: org.xipki.shells/security-shell

private String getNumber(Number no) {
 if (!hex) {
  return no.toString();
 }
 if (no instanceof Byte) {
  return "0X" + Hex.encode(new byte[]{(byte) no});
 } else if (no instanceof Short) {
  return "0X" + Integer.toHexString(Integer.valueOf((short) no));
 } else if (no instanceof Integer) {
  return "0X" + Integer.toHexString((int) no);
 } else if (no instanceof Long) {
  return "0X" + Long.toHexString((long) no);
 } else if (no instanceof Long) {
  return "0X" + Long.toHexString((long) no);
 } else if (no instanceof BigInteger) {
  return "0X" + ((BigInteger) no).toString(16);
 } else {
  return no.toString();
 }
}

代码示例来源:origin: org.xipki/ca-server

Set<CertificateInfo> removeCertificates(byte[] transactionId) {
 Args.notNull(transactionId, "transactionId");
 String hexId = Hex.encode(transactionId);
 Set<MyEntry> entries;
 synchronized  (map) {
  entries = map.remove(hexId);
 }
 if (entries == null) {
  return null;
 }
 Set<CertificateInfo> ret = new HashSet<>();
 for (MyEntry myEntry :entries) {
  ret.add(myEntry.certInfo);
 }
 return ret;
}

代码示例来源:origin: org.xipki.shells/security-shell

private String getNumber(Number no) {
 if (!hex) {
  return no.toString();
 }
 if (no instanceof Byte) {
  return "0x" + Hex.encode(new byte[]{(byte) no});
 } else if (no instanceof Short) {
  return "0x" + Integer.toHexString(Integer.valueOf((short) no));
 } else if (no instanceof Integer) {
  return "0x" + Integer.toHexString((int) no);
 } else if (no instanceof Long) {
  return "0x" + Long.toHexString((long) no);
 } else if (no instanceof Long) {
  return "0x" + Long.toHexString((long) no);
 } else if (no instanceof BigInteger) {
  return "0x" + ((BigInteger) no).toString(16);
 } else {
  return no.toString();
 }
}

代码示例来源:origin: org.xipki/security

/**
 * TODO.
 * @param id
 *          Identifier. Must not be {@code null}.
 * @param label
 *          Label. Must not be {@code null}.
 */
public P11ObjectIdentifier(byte[] id, String label) {
 this.id = Args.notNull(id, "id");
 this.label = Args.notNull(label, "label");
 this.idHex = Hex.encode(id);
}

代码示例来源:origin: org.xipki/security-pkcs11

/**
 * TODO.
 * @param id
 *          Identifier. Must not be {@code null}.
 * @param label
 *          Label. Must not be {@code null}.
 */
public P11ObjectIdentifier(byte[] id, String label) {
 this.id = ParamUtil.requireNonNull("id", id);
 this.label = ParamUtil.requireNonNull("label", label);
 this.idHex = Hex.encode(id);
}

代码示例来源:origin: org.xipki/ca-server

void addCertificate(byte[] transactionId, BigInteger certReqId, CertificateInfo certInfo,
  long waitForConfirmTill) {
 Args.notNull(transactionId, "transactionId");
 Args.notNull(certInfo, "certInfo");
 if (certInfo.isAlreadyIssued()) {
  return;
 }
 String hexTid = Hex.encode(transactionId);
 MyEntry myEntry = new MyEntry(certReqId, waitForConfirmTill, certInfo);
 synchronized (map) {
  Set<MyEntry> entries = map.get(hexTid);
  if (entries == null) {
   entries = new HashSet<>();
   map.put(hexTid, entries);
  }
  entries.add(myEntry);
 }
}

代码示例来源:origin: org.xipki/security

public static String rdnValueToString(ASN1Encodable value) {
 Args.notNull(value, "value");
 if (value instanceof ASN1String && !(value instanceof DERUniversalString)) {
  return ((ASN1String) value).getString();
 } else {
  try {
   return "#" + Hex.encode(
     value.toASN1Primitive().getEncoded(ASN1Encoding.DER));
  } catch (IOException ex) {
   throw new IllegalArgumentException("other value has no encoded form");
  }
 }
}

相关文章