예제 #1
0
파일: Address.java 프로젝트: gitonio/btcJ
  public static byte[] wifToPrivateKey(String string) {

    String wif = string;

    byte[] wif_enc = new byte[wif.length()];

    wif_enc = Base58.decode(wif);

    byte[] wif_enc_fin = new byte[wif_enc.length - 5];

    // Drop first and last four bytes
    System.arraycopy(wif_enc, 1, wif_enc_fin, 0, wif_enc.length - 5);
    return (wif_enc_fin);
  }
예제 #2
0
파일: Address.java 프로젝트: gitonio/btcJ
  public static byte[] wifChecksum(String string) {

    byte[] wif_enc = Base58.decode(string);
    byte[] wif_enc_sh = new byte[wif_enc.length - 4];

    System.arraycopy(wif_enc, 0, wif_enc_sh, 0, wif_enc.length - 4);

    byte[] hash = new byte[256];
    byte[] hash2 = new byte[256];
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA-256");
      hash = digest.digest(wif_enc_sh);
      hash2 = digest.digest(hash);

    } catch (Exception e) {
      // TODO: handle exception
    }
    byte[] checksum = new byte[4];
    System.arraycopy(hash2, 0, checksum, 0, checksum.length);
    return (checksum);
  }