private String getFingerprint(byte[] b) { String inputFingerprint; inputFingerprint = Hex.toHexString(Arrays.copyOf(Sha256Hash.create(b).getBytes(), 4)); return inputFingerprint; }
private String getFingerprint(byte[] b) { String inputFingerprint; inputFingerprint = Hex.toHexString(Arrays.copyOf(Sha256Hash.create(b).getBytes(), 4)); return inputFingerprint; }
private void parseMini(String key) throws KeyFormatException { byte[] bytes = key.getBytes(); byte[] checkBytes = new byte[31]; // 30 chars + '?' List<byte[]> allBytes = ImmutableList.of(bytes, checkBytes); if (!key.startsWith("S")) { clearDataAndThrow(allBytes, "Mini private keys must start with 'S'"); } if (bytes.length != 30) { clearDataAndThrow(allBytes, "Mini private keys must be 30 characters long"); } System.arraycopy(bytes, 0, checkBytes, 0, 30); checkBytes[30] = '?'; // Check if the sha256 hash of key + "?" starts with 0x00 if (Sha256Hash.create(checkBytes).getBytes()[0] != 0x00) { clearDataAndThrow(allBytes, "Not well formed mini private key"); } compressed = false; // Mini keys are not compressed content = Sha256Hash.create(bytes).getBytes(); clearData(allBytes); }
private void parseMini(String key) throws KeyFormatException { byte[] bytes = key.getBytes(); byte[] checkBytes = new byte[31]; // 30 chars + '?' List<byte[]> allBytes = ImmutableList.of(bytes, checkBytes); if (!key.startsWith("S")) { clearDataAndThrow(allBytes, "Mini private keys must start with 'S'"); } if (bytes.length != 30) { clearDataAndThrow(allBytes, "Mini private keys must be 30 characters long"); } System.arraycopy(bytes, 0, checkBytes, 0, 30); checkBytes[30] = '?'; // Check if the sha256 hash of key + "?" starts with 0x00 if (Sha256Hash.create(checkBytes).getBytes()[0] != 0x00) { clearDataAndThrow(allBytes, "Not well formed mini private key"); } compressed = false; // Mini keys are not compressed content = Sha256Hash.create(bytes).getBytes(); clearData(allBytes); }