List of usage examples for org.apache.commons.codec.binary Hex encodeHexString
public static String encodeHexString(byte[] data)
From source file:com.twosigma.beakerx.security.HashedMessageAuthenticationCode.java
public String toHex(byte[] buffer) { return Hex.encodeHexString(buffer); }
From source file:com.bitbreeds.webrtc.sctp.messaging.SCTPServiceTest.java
@Test public void getInit() throws DecoderException { String inp = "1388138800000000699b219101000056eed2220b0002000001000800e36d1ec9c000000480080009c00fc180820000008002002440cbb942df677d367167427655856025aa291f084401663bb48624229a6b2e4b80040006000100008003000680c10000"; byte[] out = srv.handleRequest(Hex.decodeHex(inp.toCharArray())).get(0); System.out.println(Hex.encodeHexString(out)); CRC32c crc = new CRC32c(); crc.reset();/*www .j a v a 2 s .co m*/ crc.update(out, 0, out.length); System.out.println("As Bytes: " + Hex.encodeHexString(crc.getValueAsBytes())); for (int i = 0; i < 4; i++) { out[8 + i] = (byte) 0; } System.out.println("Data: " + Hex.encodeHexString(out)); Long fing = SignalUtil.computeCRC32c(out); System.out.println("Out fingerprint: " + fing); System.out.println("Out fingerprint: " + Hex.encodeHexString(SignalUtil.longToFourBytes(fing))); String pack = "13881388eed2220b4057612702000000c5b5d8d00002000001000800c5b5d8d00007001c8871afdcecb7558bc4d8d0b21f54a9c73ac7b34200000154e9cfb01b"; byte[] back = Hex.decodeHex(pack.toCharArray()); fing = SignalUtil.computeCRC32c(back); System.out.println("Out fingerprint: " + fing); System.out.println("Out fingerprint: " + Hex.encodeHexString(SignalUtil.longToFourBytes(fing))); for (int i = 0; i < 4; i++) { back[8 + i] = (byte) 0; } System.out.println("Data: " + Hex.encodeHexString(back)); fing = SignalUtil.computeCRC32(back); System.out.println("Out fingerprint: " + fing); System.out.println("Out fingerprint: " + Hex.encodeHexString(SignalUtil.longToFourBytes(fing))); }
From source file:eu.europa.esig.dss.validation.CertificateRef.java
@Override public String toString() { return "CertificateRef[issuerName=" + issuerName + ",issuerSerial=" + issuerSerial + ",digest=" + Hex.encodeHexString(digestValue) + "]"; }
From source file:com.bitbreeds.webrtc.sctp.impl.ReliabilityParameters.java
@Override public String toString() { return "ReliabilityParameters{" + "parameter=" + parameter + ", type=" + type + ", priority=" + priority + ", label=" + new String(label) + ", protocol=" + Hex.encodeHexString(protocol) + '}'; }
From source file:com.thoughtworks.go.domain.AccessTokenTest.java
@Test void hashToken_shouldHashTheProvidedString() throws Exception { AccessToken.AccessTokenWithDisplayValue token = AccessToken.create(null, null, null, new TestingClock()); SecretKey key = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") .generateSecret(new PBEKeySpec(token.getDisplayValue().substring(8).toCharArray(), token.getSaltValue().getBytes(StandardCharsets.UTF_8), 4096, 256)); assertThat(token.getValue()).isEqualTo(Hex.encodeHexString(key.getEncoded())); }
From source file:monasca.api.domain.model.dimension.DimensionValues.java
private String generateId() { String hashstr = "metricName=" + metricName + "dimensionName=" + dimensionName; byte[] sha1Hash = DigestUtils.sha(hashstr); return Hex.encodeHexString(sha1Hash); }
From source file:io.stallion.utils.Encrypter.java
public static String encryptString(String password, String value) { String salt = KeyGenerators.string().generateKey(); SecretKeySpec skeySpec = makeKeySpec(password, salt); byte[] iv = KeyGenerators.secureRandom(16).generateKey(); String ivString = Hex.encodeHexString(iv); try {//from w w w. j a v a2 s . co m Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new GCMParameterSpec(128, iv)); /* Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(iv)); */ byte[] encrypted = cipher.doFinal(value.getBytes(Charset.forName("UTF-8"))); String s = StringUtils.strip(new Base32().encodeAsString(encrypted), "=").toLowerCase(); // Strip line breaks s = salt + ivString + s.replaceAll("(\\n|\\r)", ""); return s; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.google.u2f.gaedemo.storage.TokenStorageData.java
public JsonObject toJson() { X509Certificate x509cert = getSecurityKeyData().getAttestationCertificate(); JsonObject json = new JsonObject(); json.addProperty("enrollment_time", enrollmentTime); json.add("transports", getJsonTransports()); json.addProperty("key_handle", Hex.encodeHexString(keyHandle)); json.addProperty("public_key", Hex.encodeHexString(publicKey)); json.addProperty("issuer", x509cert.getIssuerX500Principal().getName()); try {/*from w w w. ja v a 2s . c om*/ AndroidKeyStoreAttestation androidKeyStoreAttestation = AndroidKeyStoreAttestation.Parse(x509cert); if (androidKeyStoreAttestation != null) { json.add("android_attestation", androidKeyStoreAttestation.toJson()); } } catch (CertificateParsingException e) { throw new RuntimeException(e); } return json; }
From source file:com.linkedin.databus2.schemas.SchemaId.java
@Override public String toString() { return Hex.encodeHexString(_idBytes); }
From source file:net.solarnetwork.node.hw.sma.test.SmaPacketTest.java
@Test public void encodeNetStartNonZeroSourceAddress() { SmaPacket p = SmaPacket.netStartPacket(8888); byte[] packet = p.getPacket(); log.debug("Got packet: " + Hex.encodeHexString(packet)); assertNotNull("Packet", packet); assertArrayEquals(TestUtils.bytesFromHexString("B8 22 00 00 80 00 06"), packet); }