Codota Logo
HexUtilities.encodeToHex
Code IndexAdd Codota to your IDE (free)

How to use
encodeToHex
method
in
eu.geekplace.javapinning.util.HexUtilities

Best Java code snippets using eu.geekplace.javapinning.util.HexUtilities.encodeToHex (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: Flowdalic/java-pinning

/**
 * Converts the given byte array to a String in HEX representation.
 * 
 * @param bytes the bytes to convert.
 * @return a String in HEX format.
 */
public static String encodeToHex(byte[] bytes) {
  return encodeToHex(bytes, false, false);
}
origin: Flowdalic/java-pinning

/**
 * Converts the given byte array to a String in HEX representation.
 * 
 * @param bytes the bytes to convert.
 * @return a String in HEX format.
 */
public static String encodeToHex(byte[] bytes) {
  return encodeToHex(bytes, false, false);
}
origin: Flowdalic/java-pinning

/**
 * Deprecated.
 *
 * @deprecated This method appends an unnecessary colon to the end of the
 *             HEX String, please use
 *             {@link HexUtilities#encodeToHex(byte[])} instead, which does
 *             not do this.
 */
@Deprecated
public static StringBuilder toHex(byte[] bytes, boolean uppercase) {
  return new StringBuilder(HexUtilities.encodeToHex(bytes, uppercase, true) + ":");
}
origin: Flowdalic/java-pinning

/**
 * Deprecated.
 *
 * @deprecated This method appends an unnecessary colon to the end of the
 *             HEX String, please use
 *             {@link HexUtilities#encodeToHex(byte[])} instead, which does
 *             not do this.
 */
@Deprecated
public static StringBuilder toHex(byte[] bytes, boolean uppercase) {
  return new StringBuilder(HexUtilities.encodeToHex(bytes, uppercase, true) + ":");
}
origin: Flowdalic/java-pinning

  /**
   * Deprecated.
   *
   * @deprecated This method appends an unnecessary colon to the end of the
   *             HEX String if colonSeparator is set to true, please use
   *             {@link HexUtilities#encodeToHex(byte[], boolean, boolean)}
   *             instead, which does not do this.
   */
  @Deprecated
  public static StringBuilder toHex(byte[] bytes, boolean uppercase, boolean colonSeparator) {
    return new StringBuilder(
        HexUtilities.encodeToHex(bytes, uppercase, colonSeparator) + (colonSeparator ? ":" : ""));
  }
}
origin: Flowdalic/java-pinning

  /**
   * Deprecated.
   *
   * @deprecated This method appends an unnecessary colon to the end of the
   *             HEX String if colonSeparator is set to true, please use
   *             {@link HexUtilities#encodeToHex(byte[], boolean, boolean)}
   *             instead, which does not do this.
   */
  @Deprecated
  public static StringBuilder toHex(byte[] bytes, boolean uppercase, boolean colonSeparator) {
    return new StringBuilder(
        HexUtilities.encodeToHex(bytes, uppercase, colonSeparator) + (colonSeparator ? ":" : ""));
  }
}
origin: Flowdalic/java-pinning

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
    throws CertificateException {
  final X509Certificate leafCertificate = chain[0];
  if (isPinned(leafCertificate)) {
    return;
  }
  // Throw a CertificateException with a meaningful message. Note that we
  // use CERTPLAIN, which tends to be long, so colons as separator are of
  // no use and most other software UIs show the "public key" without
  // colons (and using lowercase letters).
  final String pinHexString = HexUtilities.encodeToHex(leafCertificate.getEncoded());
  throw new CertificateNotPinnedException("Certificate not pinned. Use 'CERTPLAIN:" + pinHexString
      + "' to pin this certificate. But only pin the certificate if you are sure this is the correct certificate!");
}
origin: Flowdalic/java-pinning

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
    throws CertificateException {
  final X509Certificate leafCertificate = chain[0];
  if (isPinned(leafCertificate)) {
    return;
  }
  // Throw a CertificateException with a meaningful message. Note that we
  // use CERTPLAIN, which tends to be long, so colons as separator are of
  // no use and most other software UIs show the "public key" without
  // colons (and using lowercase letters).
  final String pinHexString = HexUtilities.encodeToHex(leafCertificate.getEncoded());
  throw new CertificateNotPinnedException("Certificate not pinned. Use 'CERTPLAIN:" + pinHexString
      + "' to pin this certificate. But only pin the certificate if you are sure this is the correct certificate!");
}
origin: Flowdalic/java-pinning

@Test
public void encodeToHexUppercase_anyByteArray_returnsCorrectHexString() {
  assertEquals("4B6E6162", HexUtilities.encodeToHex(new byte[] { 75, 110, 97, 98 }, true, false));
}
origin: Flowdalic/java-pinning

  @Test
  public void encodeToHex_emptyArray_returnsEmptyString() {
    assertEquals("", HexUtilities.encodeToHex(new byte[] {}));
  }
}
origin: Flowdalic/java-pinning

@Test
public void encodeToHex_anyByteArray_returnsCorrectHexString() {
  assertEquals("4b6e6162", HexUtilities.encodeToHex(new byte[] { 75, 110, 97, 98 }));
}
origin: Flowdalic/java-pinning

@Test
public void pinWithWhitespaces() {
  // Let's shoot some holes into the pin string
  final int[] subsequences = new int[] { 4, 17, 21, 32 };
  StringBuilder sb = new StringBuilder();
  int start = 0;
  for (int i : subsequences) {
    sb.append(PIN_STRING_W_COLON.subSequence(start, i));
    sb.append(' ');
    start = i;
  }
  sb.append(PIN_STRING_W_COLON.subSequence(start, PIN_STRING_W_COLON.length()));
  Pin pin = Pin.fromString("CERTSHA256:" + sb.toString());
  byte[] pinBytes = pin.getPinBytes();
  final String pinString = HexUtilities.encodeToHex(pinBytes, true, true);
  // String.format() appends a ':' at the very end, so we have to do that too
  assertEquals(PIN_STRING_W_COLON, pinString);
}
origin: Flowdalic/java-pinning

@Test
public void encodeToHexSemicolons_anyByteArray_returnsCorrectHexString() {
  assertEquals("4b:6e:61:62", HexUtilities.encodeToHex(new byte[] { 75, 110, 97, 98 }, false, true));
}
origin: Flowdalic/java-pinning

@Test
public void pinWithFullwidthColon() {
  Pin pin = Pin.fromString("CERTSHA256:" + PIN_STRING_W_COLON);
  byte[] pinBytes = pin.getPinBytes();
  final String pinString = HexUtilities.encodeToHex(pinBytes, true, true);
  // String.format() appends a ':' at the very end, so we have to do that too
  assertEquals(PIN_STRING_W_COLON, pinString);
}
eu.geekplace.javapinning.utilHexUtilitiesencodeToHex

Javadoc

Converts the given byte array to a String in HEX representation.

Popular methods of HexUtilities

  • decodeFromHex
    Converts the given string in HEX representation to a byte array, ignores whitespaces and semicolons

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now