user29507: I am trying to generate a public and private key set from a input string in Java. (Yes I am aware this can be a dangerous practice) I am using bitcoinj for a outside library.
I currently have:
 //public key generation from private key
 static String getPublicKey(byte[] privKey) {

    Address address = new Address(MainNetParams.get(), 
        Utils.sha256hash160(ECKey.fromPrivate(privKey, false).getPubKey()));

    return address.toString();

  }

 ///hash string to generate private key from string
 static byte[] sha256(String base) {
      try{
          MessageDigest digest = MessageDigest.getInstance("SHA-256");
          byte[] hash = digest.digest(base.getBytes("UTF-8"));
        return hash;
      } catch(Exception ex){
      throw new RuntimeException(ex);
      }
    }

 //encode private key as string to display
 static String privToString(byte[] hash) {

      StringBuffer hexString = new StringBuffer();

      for (int i = 0; i < hash.length; i++) {
          String hex = Integer.toHexString(0xff & hash[i]);
          if(hex.length() == 1) hexString.append('0');
          hexString.append(hex);
      }

      return hexString.toString();

  }

When I run the following:
Seed String: icecreampaintjob
I get the following:
Public: 1KdoiXMYFn2qa8uGGiNqfrwFRDu3j2qQNA
Private: dba1e3e22415c56af772dee422add21b7382ea35f2af77852a8069d02e47ecf4
Using bitaddress.org to cross verify I get:
Private: 5KV1o7tRK8pNqrPNYyi38nrik9r2Y85sjdgFDttnDiT1uZrQ1fj (DOESN'T MACTH) 
Public: 1KdoiXMYFn2qa8uGGiNqfrwFRDu3j2qQNA (MATCHES)
What am I missing?

user26628: As bitaddress.org BrainWallet says in its display
Private Key (Wallet Import Format): 
5KV1o7tRK8pNqrPNYyi38nrik9r2Y85sjdgFDttnDiT1uZrQ1fj 

Wallet Import Format is the usual base58 armoring applied to the privatekey value with 'version' 0x80.
See https://en.bitcoin.it/wiki/Wallet_import_format or in more detail https://en.bitcoin.it/wiki/Base58Check_encoding . 
This is basically a duplicate of Is there a way to generate a brain wallet from the command line or console? although that uses bash+dc rather than Java.
Not tested, but it looks to me like VersionChecksummedBytes(0x80,bytes).toBase58() does this.

29507: <p>I am trying to generate a public and private key set from a input string in Java. (Yes I am aware this can be a dangerous practice) I am using bitcoinj for a outside library.</p>

<p>I currently have:</p>

<pre><code> //public key generation from private key
 static String getPublicKey(byte[] privKey) {

    Address address = new Address(MainNetParams.get(), 
        Utils.sha256hash160(ECKey.fromPrivate(privKey, false).getPubKey()));

    return address.toString();

  }

 ///hash string to generate private key from string
 static byte[] sha256(String base) {
      try{
          MessageDigest digest = MessageDigest.getInstance("SHA-256");
          byte[] hash = digest.digest(base.getBytes("UTF-8"));
        return hash;
      } catch(Exception ex){
      throw new RuntimeException(ex);
      }
    }

 //encode private key as string to display
 static String privToString(byte[] hash) {

      StringBuffer hexString = new StringBuffer();

      for (int i = 0; i &lt; hash.length; i++) {
          String hex = Integer.toHexString(0xff &amp; hash[i]);
          if(hex.length() == 1) hexString.append('0');
          hexString.append(hex);
      }

      return hexString.toString();

  }
</code></pre>

<p>When I run the following:
Seed String: icecreampaintjob</p>

<p>I get the following:</p>

<p>Public: 1KdoiXMYFn2qa8uGGiNqfrwFRDu3j2qQNA</p>

<p>Private: dba1e3e22415c56af772dee422add21b7382ea35f2af77852a8069d02e47ecf4</p>

<p>Using bitaddress.org to cross verify I get:</p>

<p>Private: 5KV1o7tRK8pNqrPNYyi38nrik9r2Y85sjdgFDttnDiT1uZrQ1fj (DOESN'T MACTH) </p>

<p>Public: 1KdoiXMYFn2qa8uGGiNqfrwFRDu3j2qQNA (MATCHES)</p>

<p>What am I missing?</p>
 26628: <p>As bitaddress.org BrainWallet says in its display</p>

<pre><code>Private Key (Wallet Import Format): 
5KV1o7tRK8pNqrPNYyi38nrik9r2Y85sjdgFDttnDiT1uZrQ1fj 
</code></pre>

<p>Wallet Import Format is the usual base58 armoring applied to the privatekey value with 'version' 0x80.
<br>See <a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Wallet_import_format</a> or in more detail <a href="https://en.bitcoin.it/wiki/Base58Check_encoding" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Base58Check_encoding</a> . 
This is basically a duplicate of <a href="https://bitcoin.stackexchange.com/questions/21259/is-there-a-way-to-generate-a-brain-wallet-from-the-command-line-or-console">Is there a way to generate a brain wallet from the command line or console?</a> although that uses bash+dc rather than Java.</p>

<p>Not tested, but it looks to me like <code>VersionChecksummedBytes(0x80,bytes).toBase58()</code> does this.</p>
