diff --git a/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java b/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java index f3575fb1..2976d7e4 100644 --- a/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java +++ b/core/src/main/java/com/google/bitcoin/core/BitcoinSerializer.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +17,6 @@ package com.google.bitcoin.core; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,7 +116,7 @@ public class BitcoinSerializer { out.write(message); if (log.isDebugEnabled()) - log.debug("Sending {} message: {}", name, bytesToHexString(header) + bytesToHexString(message)); + log.debug("Sending {} message: {}", name, HEX.encode(header) + HEX.encode(message)); } /** @@ -176,19 +176,19 @@ public class BitcoinSerializer { if (header.checksum[0] != hash[0] || header.checksum[1] != hash[1] || header.checksum[2] != hash[2] || header.checksum[3] != hash[3]) { throw new ProtocolException("Checksum failed to verify, actual " + - bytesToHexString(hash) + - " vs " + bytesToHexString(header.checksum)); + HEX.encode(hash) + + " vs " + HEX.encode(header.checksum)); } if (log.isDebugEnabled()) { log.debug("Received {} byte '{}' message: {}", header.size, header.command, - Utils.bytesToHexString(payloadBytes)); + HEX.encode(payloadBytes)); } try { return makeMessage(header.command, header.size, payloadBytes, hash, header.checksum); } catch (Exception e) { - throw new ProtocolException("Error deserializing message " + Utils.bytesToHexString(payloadBytes) + "\n", e); + throw new ProtocolException("Error deserializing message " + HEX.encode(payloadBytes) + "\n", e); } } diff --git a/core/src/main/java/com/google/bitcoin/core/ECKey.java b/core/src/main/java/com/google/bitcoin/core/ECKey.java index fb7db016..b7b264f5 100644 --- a/core/src/main/java/com/google/bitcoin/core/ECKey.java +++ b/core/src/main/java/com/google/bitcoin/core/ECKey.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -407,7 +408,7 @@ public class ECKey implements EncryptableItem, Serializable { @Override public String toString() { StringBuilder b = new StringBuilder(); - b.append("pub:").append(Utils.bytesToHexString(pub.getEncoded())); + b.append("pub:").append(Utils.HEX.encode(pub.getEncoded())); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } @@ -425,7 +426,7 @@ public class ECKey implements EncryptableItem, Serializable { StringBuilder b = new StringBuilder(); b.append(toString()); if (priv != null) { - b.append(" priv:").append(Utils.bytesToHexString(priv.toByteArray())); + b.append(" priv:").append(Utils.HEX.encode(priv.toByteArray())); } return b.toString(); } diff --git a/core/src/main/java/com/google/bitcoin/core/Message.java b/core/src/main/java/com/google/bitcoin/core/Message.java index e842b882..c1a37ec6 100644 --- a/core/src/main/java/com/google/bitcoin/core/Message.java +++ b/core/src/main/java/com/google/bitcoin/core/Message.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,8 +137,8 @@ public abstract class Message implements Serializable { byte[] reserialized = bitcoinSerialize(); if (!Arrays.equals(reserialized, payloadBytes)) throw new RuntimeException("Serialization is wrong: \n" + - Utils.bytesToHexString(reserialized) + " vs \n" + - Utils.bytesToHexString(payloadBytes)); + Utils.HEX.encode(reserialized) + " vs \n" + + Utils.HEX.encode(payloadBytes)); } } diff --git a/core/src/main/java/com/google/bitcoin/core/Sha256Hash.java b/core/src/main/java/com/google/bitcoin/core/Sha256Hash.java index 79d2b977..a0aac6ea 100644 --- a/core/src/main/java/com/google/bitcoin/core/Sha256Hash.java +++ b/core/src/main/java/com/google/bitcoin/core/Sha256Hash.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +110,7 @@ public class Sha256Hash implements Serializable, Comparable { @Override public String toString() { - return Utils.bytesToHexString(bytes); + return Utils.HEX.encode(bytes); } /** diff --git a/core/src/main/java/com/google/bitcoin/core/Transaction.java b/core/src/main/java/com/google/bitcoin/core/Transaction.java index 1677feb2..f14bed01 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -669,7 +669,7 @@ public class Transaction extends ChildMessage implements Serializable { final TransactionOutput connectedOutput = outpoint.getConnectedOutput(); if (connectedOutput != null) { s.append(" hash160:"); - s.append(Utils.bytesToHexString(connectedOutput.getScriptPubKey().getPubKeyHash())); + s.append(Utils.HEX.encode(connectedOutput.getScriptPubKey().getPubKeyHash())); } } catch (Exception e) { s.append("[exception: ").append(e.getMessage()).append("]"); diff --git a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java index 98ad6d12..4aea1af3 100644 --- a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java +++ b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -312,7 +313,7 @@ public class TransactionOutput extends ChildMessage implements Serializable { if (script.isSentToAddress() || script.isPayToScriptHash()) buf.append(" to ").append(script.getToAddress(params)); else if (script.isSentToRawPubKey()) - buf.append(" to pubkey ").append(Utils.bytesToHexString(script.getPubKey())); + buf.append(" to pubkey ").append(Utils.HEX.encode(script.getPubKey())); else if (script.isSentToMultiSig()) buf.append(" to multisig"); else diff --git a/core/src/main/java/com/google/bitcoin/core/UnknownMessage.java b/core/src/main/java/com/google/bitcoin/core/UnknownMessage.java index ef210958..9f9b6e55 100644 --- a/core/src/main/java/com/google/bitcoin/core/UnknownMessage.java +++ b/core/src/main/java/com/google/bitcoin/core/UnknownMessage.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +28,6 @@ public class UnknownMessage extends EmptyMessage { @Override public String toString() { - return "Unknown message [" + name + "]: " + (payload == null ? "" : Utils.bytesToHexString(payload)); + return "Unknown message [" + name + "]: " + (payload == null ? "" : Utils.HEX.encode(payload)); } - } diff --git a/core/src/main/java/com/google/bitcoin/core/Utils.java b/core/src/main/java/com/google/bitcoin/core/Utils.java index ae5b81a1..4cc02207 100644 --- a/core/src/main/java/com/google/bitcoin/core/Utils.java +++ b/core/src/main/java/com/google/bitcoin/core/Utils.java @@ -20,8 +20,10 @@ package com.google.bitcoin.core; import com.google.common.base.Charsets; import com.google.common.collect.Lists; import com.google.common.collect.Ordering; +import com.google.common.io.BaseEncoding; import com.google.common.primitives.Ints; import com.google.common.primitives.UnsignedLongs; + import org.spongycastle.crypto.digests.RIPEMD160Digest; import org.spongycastle.util.encoders.Hex; @@ -185,19 +187,9 @@ public class Utils { } /** - * Returns the given byte array hex encoded. + * Hex encoding used throughout the framework. Use with HEX.encode(byte[]) or HEX.decode(CharSequence). */ - public static String bytesToHexString(byte[] bytes) { - StringBuffer buf = new StringBuffer(bytes.length * 2); - for (byte b : bytes) { - String s = Integer.toString(0xFF & b, 16); - if (s.length() < 2) - buf.append('0'); - buf.append(s); - } - return buf.toString(); - } - + public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase(); /** * Returns a copy of the given byte array in reverse order. diff --git a/core/src/main/java/com/google/bitcoin/script/ScriptChunk.java b/core/src/main/java/com/google/bitcoin/script/ScriptChunk.java index f624edf4..e8154578 100644 --- a/core/src/main/java/com/google/bitcoin/script/ScriptChunk.java +++ b/core/src/main/java/com/google/bitcoin/script/ScriptChunk.java @@ -25,7 +25,6 @@ import java.util.Arrays; import javax.annotation.Nullable; -import static com.google.bitcoin.core.Utils.bytesToHexString; import static com.google.bitcoin.script.ScriptOpCodes.OP_0; import static com.google.bitcoin.script.ScriptOpCodes.OP_1; import static com.google.bitcoin.script.ScriptOpCodes.OP_16; @@ -145,7 +144,7 @@ public class ScriptChunk { // Data chunk buf.append(getPushDataName(opcode)); buf.append("["); - buf.append(bytesToHexString(data)); + buf.append(Utils.HEX.encode(data)); buf.append("]"); } else { // Small num diff --git a/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java b/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java index 20755c61..2d758283 100644 --- a/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java +++ b/core/src/main/java/com/google/bitcoin/store/PostgresFullPrunedBlockStore.java @@ -1,5 +1,6 @@ /* * Copyright 2014 BitPOS Pty Ltd. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -488,7 +489,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore { try { if (log.isDebugEnabled()) - log.debug("Looking for undoable block with hash: " + Utils.bytesToHexString(hashBytes)); + log.debug("Looking for undoable block with hash: " + Utils.HEX.encode(hashBytes)); PreparedStatement findS = conn.get().prepareStatement("select 1 from undoableBlocks where hash = ?"); findS.setBytes(1, hashBytes); @@ -507,8 +508,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore { s.setBytes(3, hashBytes); if (log.isDebugEnabled()) - log.debug("Updating undoable block with hash: " + Utils.bytesToHexString(hashBytes)); - + log.debug("Updating undoable block with hash: " + Utils.HEX.encode(hashBytes)); if (transactions == null) { s.setBytes(1, txOutChanges); @@ -530,8 +530,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore { s.setInt(2, height); if (log.isDebugEnabled()) - log.debug("Inserting undoable block with hash: " + Utils.bytesToHexString(hashBytes) + " at height " + height); - + log.debug("Inserting undoable block with hash: " + Utils.HEX.encode(hashBytes) + " at height " + height); if (transactions == null) { s.setBytes(3, txOutChanges); diff --git a/core/src/main/java/com/google/bitcoin/wallet/KeyChainGroup.java b/core/src/main/java/com/google/bitcoin/wallet/KeyChainGroup.java index dc218a57..15b7177d 100644 --- a/core/src/main/java/com/google/bitcoin/wallet/KeyChainGroup.java +++ b/core/src/main/java/com/google/bitcoin/wallet/KeyChainGroup.java @@ -1,5 +1,6 @@ /** * Copyright 2014 Mike Hearn + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -488,7 +489,7 @@ public class KeyChainGroup { builder.append(address.toString()); } builder.append(" hash160:"); - builder.append(Utils.bytesToHexString(key.getPubKeyHash())); + builder.append(Utils.HEX.encode(key.getPubKeyHash())); builder.append(" "); builder.append(includePrivateKeys ? key.toStringWithPrivate() : key.toString()); builder.append("\n"); diff --git a/core/src/test/java/com/google/bitcoin/core/AddressTest.java b/core/src/test/java/com/google/bitcoin/core/AddressTest.java index cac1ad96..bf556dac 100644 --- a/core/src/test/java/com/google/bitcoin/core/AddressTest.java +++ b/core/src/test/java/com/google/bitcoin/core/AddressTest.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,10 +46,10 @@ public class AddressTest { @Test public void decoding() throws Exception { Address a = new Address(testParams, "n4eA2nbYqErp7H6jebchxAN59DmNpksexv"); - assertEquals("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc", Utils.bytesToHexString(a.getHash160())); + assertEquals("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc", Utils.HEX.encode(a.getHash160())); Address b = new Address(mainParams, "17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL"); - assertEquals("4a22c3c4cbb31e4d03b15550636762bda0baf85a", Utils.bytesToHexString(b.getHash160())); + assertEquals("4a22c3c4cbb31e4d03b15550636762bda0baf85a", Utils.HEX.encode(b.getHash160())); } @Test diff --git a/core/src/test/java/com/google/bitcoin/core/BitcoinSerializerTest.java b/core/src/test/java/com/google/bitcoin/core/BitcoinSerializerTest.java index 33b0c7a8..c2552528 100644 --- a/core/src/test/java/com/google/bitcoin/core/BitcoinSerializerTest.java +++ b/core/src/test/java/com/google/bitcoin/core/BitcoinSerializerTest.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Noa Resare + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +17,6 @@ package com.google.bitcoin.core; - import com.google.bitcoin.params.MainNetParams; import org.junit.Test; import org.spongycastle.util.encoders.Hex; @@ -169,7 +169,7 @@ public class BitcoinSerializerTest { assertNull(block.transactions); - assertEquals(Utils.bytesToHexString(block.getMerkleRoot().getBytes()), + assertEquals(Utils.HEX.encode(block.getMerkleRoot().getBytes()), "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); } diff --git a/core/src/test/java/com/google/bitcoin/core/ECKeyTest.java b/core/src/test/java/com/google/bitcoin/core/ECKeyTest.java index ad28708c..79bb353a 100644 --- a/core/src/test/java/com/google/bitcoin/core/ECKeyTest.java +++ b/core/src/test/java/com/google/bitcoin/core/ECKeyTest.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -206,8 +207,8 @@ public class ECKeyTest { ECKey key = new ECKey(); ECKey key1 = new DumpedPrivateKey(TestNet3Params.get(), key.getPrivateKeyEncoded(TestNet3Params.get()).toString()).getKey(); - assertEquals(Utils.bytesToHexString(key.getPrivKeyBytes()), - Utils.bytesToHexString(key1.getPrivKeyBytes())); + assertEquals(Utils.HEX.encode(key.getPrivKeyBytes()), + Utils.HEX.encode(key1.getPrivKeyBytes())); } } @@ -278,7 +279,7 @@ public class ECKeyTest { public void testEncryptedCreate() throws Exception { ECKey unencryptedKey = new ECKey(); byte[] originalPrivateKeyBytes = checkNotNull(unencryptedKey.getPrivKeyBytes()); - log.info("Original private key = " + Utils.bytesToHexString(originalPrivateKeyBytes)); + log.info("Original private key = " + Utils.HEX.encode(originalPrivateKeyBytes)); EncryptedData encryptedPrivateKey = keyCrypter.encrypt(unencryptedKey.getPrivKeyBytes(), keyCrypter.deriveKey(PASSWORD1)); ECKey encryptedKey = ECKey.fromEncrypted(encryptedPrivateKey, keyCrypter, unencryptedKey.getPubKey()); assertTrue(encryptedKey.isEncrypted()); @@ -424,7 +425,7 @@ public class ECKeyTest { // We dump failed data to error log because this test is not expected to be deterministic ECKey key = new ECKey(); if (!ECKey.isPubKeyCanonical(key.getPubKey())) { - log.error(Utils.bytesToHexString(key.getPubKey())); + log.error(Utils.HEX.encode(key.getPubKey())); fail(); } @@ -434,7 +435,7 @@ public class ECKeyTest { byte[] encodedSig = Arrays.copyOf(sigBytes, sigBytes.length + 1); encodedSig[sigBytes.length] = (byte) (Transaction.SigHash.ALL.ordinal() + 1); if (!TransactionSignature.isEncodingCanonical(encodedSig)) { - log.error(Utils.bytesToHexString(sigBytes)); + log.error(Utils.HEX.encode(sigBytes)); fail(); } } diff --git a/core/src/test/java/com/google/bitcoin/core/LazyParseByteCacheTest.java b/core/src/test/java/com/google/bitcoin/core/LazyParseByteCacheTest.java index 69f06d94..48d79bf6 100644 --- a/core/src/test/java/com/google/bitcoin/core/LazyParseByteCacheTest.java +++ b/core/src/test/java/com/google/bitcoin/core/LazyParseByteCacheTest.java @@ -1,5 +1,6 @@ /** * Copyright 2011 Steve Coughlan. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -510,8 +511,8 @@ public class LazyParseByteCacheTest { if (sup.length < sub.length) return false; - String superstring = Utils.bytesToHexString(sup); - String substring = Utils.bytesToHexString(sub); + String superstring = Utils.HEX.encode(sup); + String substring = Utils.HEX.encode(sub); int ind = superstring.indexOf(substring); diff --git a/core/src/test/java/com/google/bitcoin/core/PeerAddressTest.java b/core/src/test/java/com/google/bitcoin/core/PeerAddressTest.java index 6aeb08da..60af6211 100644 --- a/core/src/test/java/com/google/bitcoin/core/PeerAddressTest.java +++ b/core/src/test/java/com/google/bitcoin/core/PeerAddressTest.java @@ -1,5 +1,6 @@ /* * Copyright 2011 Google Inc. + * Copyright 2014 Andreas Schildbach * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ public class PeerAddressTest String fromSpec = "010000000000000000000000000000000000ffff0a000001208d"; PeerAddress pa = new PeerAddress(MainNetParams.get(), Hex.decode(fromSpec), 0, 0); - String reserialized = Utils.bytesToHexString(pa.bitcoinSerialize()); + String reserialized = Utils.HEX.encode(pa.bitcoinSerialize()); assertEquals(reserialized,fromSpec ); } @@ -40,6 +41,6 @@ public class PeerAddressTest public void testBitcoinSerialize() throws Exception { PeerAddress pa = new PeerAddress(InetAddress.getByName(null), 8333, 0); assertEquals("000000000000000000000000000000000000ffff7f000001208d", - Utils.bytesToHexString(pa.bitcoinSerialize())); + Utils.HEX.encode(pa.bitcoinSerialize())); } } diff --git a/core/src/test/java/com/google/bitcoin/crypto/KeyCrypterScryptTest.java b/core/src/test/java/com/google/bitcoin/crypto/KeyCrypterScryptTest.java index b896485c..98e1f9f4 100644 --- a/core/src/test/java/com/google/bitcoin/crypto/KeyCrypterScryptTest.java +++ b/core/src/test/java/com/google/bitcoin/crypto/KeyCrypterScryptTest.java @@ -1,5 +1,6 @@ /** * Copyright 2013 Jim Burton. + * Copyright 2014 Andreas Schildbach * * Licensed under the MIT license (the "License"); * you may not use this file except in compliance with the License. @@ -67,9 +68,9 @@ public class KeyCrypterScryptTest { // Decrypt. byte[] reborn = keyCrypter.decrypt(encryptedPrivateKey, keyCrypter.deriveKey(PASSWORD1)); - log.debug("Original: " + Utils.bytesToHexString(TEST_BYTES1)); - log.debug("Reborn : " + Utils.bytesToHexString(reborn)); - assertEquals(Utils.bytesToHexString(TEST_BYTES1), Utils.bytesToHexString(reborn)); + log.debug("Original: " + Utils.HEX.encode(TEST_BYTES1)); + log.debug("Reborn : " + Utils.HEX.encode(reborn)); + assertEquals(Utils.HEX.encode(TEST_BYTES1), Utils.HEX.encode(reborn)); } /** @@ -94,7 +95,7 @@ public class KeyCrypterScryptTest { assertNotNull(encryptedPrivateKey); byte[] reconstructedPlainBytes = keyCrypter.decrypt(encryptedPrivateKey,keyCrypter.deriveKey(password)); - assertEquals(Utils.bytesToHexString(plainText.getBytes()), Utils.bytesToHexString(reconstructedPlainBytes)); + assertEquals(Utils.HEX.encode(plainText.getBytes()), Utils.HEX.encode(reconstructedPlainBytes)); System.out.print('.'); } System.out.println(" Done."); @@ -129,13 +130,13 @@ public class KeyCrypterScryptTest { // Encrypt bytes. EncryptedData encryptedPrivateKey = keyCrypter.encrypt(TEST_BYTES1, keyCrypter.deriveKey(PASSWORD1)); assertNotNull(encryptedPrivateKey); - log.debug("\nEncrypterDecrypterTest: cipherBytes = \nlength = " + encryptedPrivateKey.encryptedBytes.length + "\n---------------\n" + Utils.bytesToHexString(encryptedPrivateKey.encryptedBytes) + "\n---------------\n"); + log.debug("\nEncrypterDecrypterTest: cipherBytes = \nlength = " + encryptedPrivateKey.encryptedBytes.length + "\n---------------\n" + Utils.HEX.encode(encryptedPrivateKey.encryptedBytes) + "\n---------------\n"); byte[] rebornPlainBytes = keyCrypter.decrypt(encryptedPrivateKey, keyCrypter.deriveKey(PASSWORD1)); - log.debug("Original: " + Utils.bytesToHexString(TEST_BYTES1)); - log.debug("Reborn1 : " + Utils.bytesToHexString(rebornPlainBytes)); - assertEquals(Utils.bytesToHexString(TEST_BYTES1), Utils.bytesToHexString(rebornPlainBytes)); + log.debug("Original: " + Utils.HEX.encode(TEST_BYTES1)); + log.debug("Reborn1 : " + Utils.HEX.encode(rebornPlainBytes)); + assertEquals(Utils.HEX.encode(TEST_BYTES1), Utils.HEX.encode(rebornPlainBytes)); } @Test @@ -151,13 +152,13 @@ public class KeyCrypterScryptTest { EncryptedData encryptedPrivateKey = keyCrypter.encrypt(plainBytes, keyCrypter.deriveKey(PASSWORD1)); assertNotNull(encryptedPrivateKey); - //log.debug("\nEncrypterDecrypterTest: cipherBytes = \nlength = " + cipherBytes.length + "\n---------------\n" + Utils.bytesToHexString(cipherBytes) + "\n---------------\n"); + //log.debug("\nEncrypterDecrypterTest: cipherBytes = \nlength = " + cipherBytes.length + "\n---------------\n" + Utils.HEX.encode(cipherBytes) + "\n---------------\n"); byte[] rebornPlainBytes = keyCrypter.decrypt(encryptedPrivateKey, keyCrypter.deriveKey(PASSWORD1)); - log.debug("Original: (" + i + ") " + Utils.bytesToHexString(plainBytes)); - log.debug("Reborn1 : (" + i + ") " + Utils.bytesToHexString(rebornPlainBytes)); - assertEquals(Utils.bytesToHexString(plainBytes), Utils.bytesToHexString(rebornPlainBytes)); + log.debug("Original: (" + i + ") " + Utils.HEX.encode(plainBytes)); + log.debug("Reborn1 : (" + i + ") " + Utils.HEX.encode(rebornPlainBytes)); + assertEquals(Utils.HEX.encode(plainBytes), Utils.HEX.encode(rebornPlainBytes)); } } }