Computes a digest from a string using SHA-256. Learn more about SHA-256 in the SHA-256 explained section of this page.
I use Bouncy Castle for the implementation.
What is SHA-256?
SHA-256 is a message-digest algorithm. It's used to compute a hash value in cryptography. So what's an hash function then? Simply put, a hash function takes a block of data and returns a fixed-size bit string (hash value). The data used by hash functions is referred to as a "message", while the computed hash value is referred to as the "message digest".
When to use SHA-256?
SHA-256, like other hash functions, is used in digital signatures, message authentication codes, to index data in hash tables, for finger-printing, to detect duplicate data, uniquely identify files, and as checksums to detect accidental data corruption.
How big is a SHA-256 hash value?
SHA-256 produces a 256-bit (32 bytes) hash value. It's usually represented as a hexadecimal number of 64 digits.
How can I decrypt SHA-256?
You can't! SHA-256 is NOT an encryption algorithm! A lot of people are under the impression that SHA-256 encrypts data. It does no such thing. All it does is compute a hash value for a given set of data.
How do I reverse SHA-256?
You can't! SHA-256 is NOT reversible. Hash functions are used as one-way methods. They take the data (messages) and compute hash values (digests).
The inverse can't be done.
To better explain why a SHA-256 is NOT reversible, here's very simple example:
Using SHA-256 on text data of 750,000 characters, we obtain a mere 64 digits digest. Now if I wanted to revert this, how could I possibly determine with exactitude which 750,000 characters were used from just 64 digits?!? This would be the BEST compression algorithm in the world :P