0

Using SHA-256 I created a 32 length byte array that I have no problem converting to a String using

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < byteArray.length; i++){
            sb.append(String.format("%02X", byteArray[i]));
        }
        String str = sb.toString().toLowerCase();

However, I am having trouble converting the resulting 64 character String back into a 32 byte array. How should I proceed?

Crowley
  • 67
  • 7
  • Since this is "byte array to hex string", to go back look for the inverse: [*"hex string to byte array"*](http://stackoverflow.com/search?q=hex+string+to+byte+array+%5Bjava%5D). – user2864740 Mar 17 '15 at 20:12
  • Made it easy to find: http://stackoverflow.com/questions/6650650/hex-encoded-string-to-byte-array , http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java – user2864740 Mar 17 '15 at 20:13

0 Answers0