Key { public String encode() { return this.type + Key.separator + DataUtils.byteArrayToHexString(this.key); } Key(String type, byte[] key); static Key decodeKey(String encodedKey); static Key decodeKey(String encodedKey, String expectedKeyType); String encode(); static final String separator; public byte[] key; public String type; }
@Test public void testEncodePrivate() throws Exception { byte[] keyAsByte = DataUtils.hexStringToByteArray(Common.myPrivateKeyExtract); Key key = new Key(Key.KeyType.PRIVATE, keyAsByte); Assert.assertNotNull("key instance", key); Assert.assertEquals(Key.KeyType.PRIVATE, key.type); Assert.assertEquals(key.key, keyAsByte); Assert.assertEquals(key.encode(), Common.myPrivateKey); }