简体   繁体   中英

How to encode a string to SHA-1 on windows using the command line?

I can only use the command line for this task, how would you convert echo -n "mystringtoencode" | sha1sum echo -n "mystringtoencode" | sha1sum so it works on windows?

Or more broadly, what is the command to encode a string with sha-1 on windows?

Thanks!

According to a Microsoft Support page :

FCIV -md5 -sha1 path\filename.ext

It doesn't look like it's available normally (my up-to-date Win10 doesn't have it). You'll have to download it.

If your scenario lets you use PowerShell, there's the Get-FileHash command which has MD5 and a number of versions of SHA. This might be your best no-download option.

If you really want Windows to have all the small tools that Linux has, you can get a big list of them by downloading GOW (GNU On Windows) and adding it's binaries to your path. This includes sha1sum. These are Windows binaries running in the Windows kernel.

There's always the Windows Subsystem for Linux (WSL) which also has a lot of Linux tools running in a more Linux-like environment but I think that might be a bit over kill for hashing files. These will be Linux binaries running on a version of the Linux kernel. It's actually not bad.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM