30

I found tutorials on how to find the sha256 hash of files, but cannot seem to find one on simple text (not a text file). Does anyone know how to do that?

zerosofthezeta
  • 402
  • 1
  • 4
  • 8

1 Answers1

55

You can echo the text and pipe it to shasum. You'll want to use the -a 256 option to calculate sha256:

Thanks to JMY1000 in the comments: Since echo adds a newline by default, -n should probably be added in order to get the proper shasum of the text without this newline.

echo -n "simple text" | shasum -a 256

If you want to get the hash value for a text which is already open in an editor, copy it to the clipboard and run

pbpaste | shasum -a 256
nohillside
  • 100,768
Scot
  • 8,045