BTC sha256 hashes are hex encoded (as sha256 spits out bytes not a string), why is this? Surely using base58 would be more efficient as would use less space (would output a shorter string)

2 Answers 2


SHA256 hashes are encoded in plain binary in bitcoin protocol and in block storage (32-bytes in little-endian byte order when treated as integers, which makes them effectively "base256"). The textual hex encoding is merely used for displaying and inputting hashes into the software. Hex is a widely used and understood format for representing arrays of bytes. Also, most cryptographic APIs already support parsing of hex strings into big integers and such, but base58 is not really widely used outside of Bitcoin.

There seems like little reason to change the way I/O of hashes is done as it would only add to confusion as to what a string is for. The purpose of Base58Check strings was not merely to shorten them (as Base64 could've been used for this), but also to eliminate some characters which look alike or are incompatible with the URI format because bitcoin addresses are intended for sharing.

  • Yeah i get why base58 is used rather than base64, but why was hex chosen to visulaise the hashes? Is it insecure to encode hashes with base58 on a protocol level? The reason i ask is that i am currently coding a cryptocurrency in rust. I am currently encoding the hashes in base58 and reuiring hashes have at least 4 A's before them as other difficulty algos (the ahsh must be < the diff) dont work as the hashes are never samll enough Commented Mar 29, 2020 at 9:51
  • See my answer: hex is much nicer to debug things. Commented Mar 29, 2020 at 17:13

Mark H's answer is correct, but I think there is a more fundamental point: addresses are directly intended for human consumption. Transaction hashes (as well as public keys, block hashes, raw scripts, raw transactions, ...) are not. They are sometimes visualized, but this is primarily for debugging purposes. And hexadecimal is a very natural choice for debugging, as it's easy to see which bytes correspond to which characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.