Stories Behind the Tech:PowerShell
-
echo "this is my string I want to hash" | sha256sum
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Is sha256sum a Bash internal command or something you have to install? If the latter, you can do it in Windows without piping and installing anything, and more: [Windows: MD5/SHA256 CheckSum - Built-In Utility - ShellHacks](https://www.shellhacks.com/windows-md5-sha256-checksum-built-in-utility/)
-
That's a really interesting shell command I had never seen. Unfortuantely, it is actually not quite generating the correct sha256 hash. I had to prove it to myself first. I tried:
$ echo "aardvark" | sha256sum
You get the value: aabbc5c9b7ec8ef2facd0dbee5b3f7f8836b53544583c21894d25ca4cf98a188 That's incorrect. The correct value is: cf9c1cb89584bf8c4176a37c2c954a8dc56077d3ba65ee44011e62ab7c63ce2d Independent Hash Creator: VirusTotal As a way to prove this I created a file (aardvark.txt) with the word aardvark but no line terminator or file terminator in it and uploaded it to VirusTotal (runs a sha256 on every file it receives) and you can see that it confirms the same output that I get from my PowerShell script at this link[^]. If you look at the top of that page you'll see the value of the word aardvark which is: cf9c1cb89584bf8c4176a37c2c954a8dc56077d3ba65ee44011e62ab7c63ce2d The problem with the script you've provided is that it seems to include a \n with the txt that is hashed. Here's a snapshot of me trying your values[^] and then inputting the value of my aardvark.txt file (which includes no file terminator or line terminator to your script. I hope you find this as interesting as I do. :thumbsup:
We both forgot to put
echo -n
to suppress the trailing newline.Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
We both forgot to put
echo -n
to suppress the trailing newline.Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Is sha256sum a Bash internal command or something you have to install? If the latter, you can do it in Windows without piping and installing anything, and more: [Windows: MD5/SHA256 CheckSum - Built-In Utility - ShellHacks](https://www.shellhacks.com/windows-md5-sha256-checksum-built-in-utility/)
It's not a bash builtin, but it is provided by a standard (default install) package.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Is sha256sum a Bash internal command or something you have to install? If the latter, you can do it in Windows without piping and installing anything, and more: [Windows: MD5/SHA256 CheckSum - Built-In Utility - ShellHacks](https://www.shellhacks.com/windows-md5-sha256-checksum-built-in-utility/)
It is a (built-in) bash shell command (at least here on Ubuntu 22.04.4). I just tried the certutil on my windows machine and had it generate a SHA256 of my aardvark.txt file and it worked great.
certutil -hashfile aardvark.txt SHA256
SHA256 hash of aardvark.txt:
cf9c1cb89584bf8c4176a37c2c954a8dc56077d3ba65ee44011e62ab7c63ce2dThanks for the insight into that one. Really great.:thumbsup:
-
When I sit in front of a bash shell prompt I feel the entire computer spread out in front of me. When I sit in front of a Powershell prompt I feel like I'm peeking through a tiny hole into a big confusing mess. The first Microsoft PC I used had 640K of memory and twin floppy disks. It felt like an amusing toy next to the Sun Microsystems workstation on my desk. Forty years later it still f*****g does!
Derek Hunter wrote:
When I sit in front of a bash shell prompt I feel the entire computer spread out in front of me. When I sit in front of a Powershell prompt I feel like I'm peeking through a tiny hole into a big confusing mess.
That is a very good way to express the feeling of sys admin in windows versus Linux. And, that is exactly what Jeffrey Snover literally fought the internal people at MS about. The other people were like, "no look you can move your mouse and do all that stuff". Snover was like, "Ok, so you have 100 machines that you need to set a value on as a sys admin and youre going to have the sys admin login to each box and move the mouse to set the value?!!!" It's a great interview.
-
It's not a bash builtin, but it is provided by a standard (default install) package.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Adam Gordon Bell is a great podcaster who investigates the stories behind the code. I've enjoyed a great many of his podcasts. This one, where he interviews Jeffrey Snover (creator of PowerShell) is fantastic. Navigating Corporate Giants Jeffrey Snover and the Making of PowerShell - CoRecursive Podcast[^] Snover reveals interesting details that, I believe, will open your eyes to why Microsoft has backed certain technologies then left them for dead. Really great insider stuff you're not going to hear anywhere else. The podcast is also available via Apple Podcasts. Listent to it while you're working & I'm guessing you'll stop working to focus on it more. :rolleyes:
The raw RSS feed, as God intended podcasts to be used: [CoRecursive: Coding Stories](https://corecursive.libsyn.com/feed)
raddevus wrote:
The podcast is also available via Apple Podcasts.
Don't feed the beast.
-
Adam Gordon Bell is a great podcaster who investigates the stories behind the code. I've enjoyed a great many of his podcasts. This one, where he interviews Jeffrey Snover (creator of PowerShell) is fantastic. Navigating Corporate Giants Jeffrey Snover and the Making of PowerShell - CoRecursive Podcast[^] Snover reveals interesting details that, I believe, will open your eyes to why Microsoft has backed certain technologies then left them for dead. Really great insider stuff you're not going to hear anywhere else. The podcast is also available via Apple Podcasts. Listent to it while you're working & I'm guessing you'll stop working to focus on it more. :rolleyes:
That was interesting to read. Adam's interjections got a bit annoying but that's OK. I found one line in particular to be hilarious :
Quote:
I’ve never seen anybody use a GUI in a clever way. Ever. There’s no cleverness to it.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
Thanks for the clarity on that. I can never tell my built-ins from my packages in the ground. :laugh:
A couple of quick tricks:
help -d
will list all builtins with a (very) brief synopsiswhich _command_
will show the executable path for non-builtins Note that there are some that have a foot in both camps, for exampleprintf
(That one's a bitch - the builtin behaves subtly differently from the external program.) Just_command_
will run the builtin, specify a path to force the external one, like_/usr/bin/command_
. ...and of coursetype -a _command_
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012