Add base-64 encoding support to SHA1
Summary:
SHA1's toString method encodes it using base-16, which is the typical
representation for a SHA1 hash. However in some cases we want a more
compact string representation (the particular format may not
matter). We can use base-64 for this, as its the most compact (power
of 2) representation while keeping the output relatively readable. Add
a toStringBase64 method to SHA1. Encoding a SHA1 hash in base-64
requires 27 characters. However 27 base-64 characters can encode 162
bits, so there's 2 unused bits in the encoding. This can be handy to
encode a little bit extra data directly into the hash, so provide a
mechanism to do so.
Reviewed By: jjgriego
Differential Revision:
D22422725
fbshipit-source-id:
f107451866152690b5cb395c964dd61710b447b6