DEV Community

Lumin
Lumin

Posted on

Generate SHA256 Hash on OSX Command Line

Just run echo -n any string | shasum -a 256 | awk '{ print $1 }'

Fin.

Note

  • AWK are not acronym of awkward but it's acronym of the family names of its authors (Alfred Aho, Peter Weinberger, and Brian Kernighan)
  • Added -n to echo to prevent new line so that we will get the right SHA256 from our input string without newline 😺 (suggestion from @fallenpixel)

Top comments (1)

Collapse
 
fallenpixel profile image
Eric Lehmann

Just something to be aware of. echo will include a terminal new line character at the end of your string without the -n flag.