PowerShell hashing
-
- Posts: 4313
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
PowerShell hashing
I did not know this. <smile>
If you have Windows PowerShell, open it.
1) Type 'Get-FileHash'.
2) Follow that with a Drag & Drop of a file to hash.
3) Follow that with '-Algorithm <whatever>' where <whatever> is MD5, SHA1 or SHA256.
4) Press Enter.
We now get the hash.
We can use SHA512 but on my machine, it runs out of space and clips the result.
Of course, I may be the only one who did not know this but I doubt that.
Where did I learn about it? I am on 'How-To Geek' mailing list. I have seen a few 'Didn't know that' topics of late.
If you have Windows PowerShell, open it.
1) Type 'Get-FileHash'.
2) Follow that with a Drag & Drop of a file to hash.
3) Follow that with '-Algorithm <whatever>' where <whatever> is MD5, SHA1 or SHA256.
4) Press Enter.
We now get the hash.
We can use SHA512 but on my machine, it runs out of space and clips the result.
Of course, I may be the only one who did not know this but I doubt that.
Where did I learn about it? I am on 'How-To Geek' mailing list. I have seen a few 'Didn't know that' topics of late.
Re: PowerShell hashing
Nice.
Code: Select all
Algorithm Hash Path
--------- ---- ----
SHA256 582432F3A286ADA8240B859DFC2707B09C4D90E2387335D86E8CE824D81EF4D4 C:\Users\User\Desktop\fb-manu...
PS C:\Users\User\Desktop>
Re: PowerShell hashing
For those on linux, similar tools via the terminal: md5sum, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum or via shasum with additional parameters. E.g.:
Code: Select all
sha256sum test_time.cir
9f1582e9bf5e6b03ed71a828c1a49d5556ec41f58bc7789b452908247305a4a3 test_time.cir
-
- Posts: 4313
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: PowerShell hashing
Well done Linux!
Re: PowerShell hashing
This has been in Windows for a while, the powershell thing is (probably) just a wrapper around it.
certutil -hashfile fileName HashType
Hashtype is MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512
certutil -hashfile fileName HashType
Hashtype is MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512
-
- Posts: 4313
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: PowerShell hashing
@macko17
Thanks for that - we live and learn.
The nice thing about certutil is that there is no clipping on SHA512.
Thanks for that - we live and learn.
The nice thing about certutil is that there is no clipping on SHA512.
Re: PowerShell hashing
Are you referring to the output format? You can easily change that, e.g. like this:deltarho[1859] wrote:We can use SHA512 but on my machine, it runs out of space and clips the result.
Code: Select all
PS D:\dev\fbc> Get-FileHash readme.txt -Algorithm SHA512 | Format-List
Algorithm : SHA512
Hash : D3B48B6756D35DB2A9E91CA135FDEE303F2DAF7FF139EC46D3512A2329E080D45D4149EA15013B0B8ED8E01CA14332D7E4AA5C578C0
F6FEEF26AA04DDE9B3428
Path : D:\dev\fbc\readme.txt
PS D:\dev\fbc> (Get-FileHash readme.txt -Algorithm SHA512).Hash
D3B48B6756D35DB2A9E91CA135FDEE303F2DAF7FF139EC46D3512A2329E080D45D4149EA15013B0B8ED8E01CA14332D7E4AA5C578C0F6FEEF26AA04DDE9B3428
PS D:\dev\fbc>
-
- Posts: 4313
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: PowerShell hashing
@St_W Thank you.
This thread is turning into a KB. <smile> I must get a PowerShell tutorial for my Kindle Paperwhite - there are a few to choose from.
This thread is turning into a KB. <smile> I must get a PowerShell tutorial for my Kindle Paperwhite - there are a few to choose from.
-
- Posts: 1002
- Joined: Jul 14, 2005 23:41
Re: PowerShell hashing
Google just release "Tink", a simple, cross-platform cryptography library:
https://github.com/google/tink
You might be interested in that?
I haven't investigated to see if it can be easily called from a FB program.
https://github.com/google/tink
You might be interested in that?
I haven't investigated to see if it can be easily called from a FB program.
Re: PowerShell hashing
It can be done programmatically, too. Source:Output with fbc.exe (31.1.16, 1979904 bytes) dragged over the exe:Under the hood are the Crypt*Hash API functions.
Code: Select all
If_ GetHash(FileRead$(<CL$()>), LastFileSize, md5) Then Inkey "The MD5 of ", CL$(), " is ", Hex$(xmm0)
Code: Select all
The MD5 of C:\AllBasics\FreeBasic\Fb64\bin\fbc.exe is 7101A636 562F2F90 C8C698A7 3282A9A6
-
- Posts: 4313
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: PowerShell hashing
PaulSquires wrote:I haven't investigated to see if it can be easily called from a FB program.
I cannot speak for others but I have been 'doing' crypto for over 13 years and have been adding to my own 'library' over the years. I first used ECDSA with my Encrypternet so now have code for that. I already had code for AES-CBC, RSA, and SHA256 used in Encrypternet, which comes in at only just over 150KB. I have looked at many crypto libraries but never took to any of them - I'd much rather code lower down with the Windows APIs. An analogy would be the SDK programmers at PowerBASIC not taking to DDT.with the release of version 1.2.0. This is a milestone for the project, as it’s the first version to have well-tested support for Android, iOS, and C++. (Go and JavaScript support are currently in-development.)