You may have come across this image on Wikipedia when reading about endianness. While it is great, in practice when I’m viewing content in memory, it is displayed horizontally instead of vertically. So for those visual people out there, here is another take.
Big endian is defined at placing the Most Significant Figure (MSF) and placing it in the lowest memory address. (In this case a). Little endian is placing the Least Significant Figure (LSF) in the lowest memory address.
The sha256 of the character “a” is: ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb. Below is how it is represented in memory. Note that the result has been truncated to show only 16 bytes and I’m using an intel based PC which is little endian by default.
Printing the variable S shows little endian meaning you can read the output from left to right.
The hash variable beneath it shows the result in big endian.
It is easy to get confused so the secret that I have found is to keep a reference chart or your favourite web link handy to refer to when required.
Speaking of web link, this is a cool write up from another angle.