How to get an MD5 checksum in PowerShell

后端 未结 17 1652
夕颜
夕颜 2020-11-28 01:14

I would like to calculate an MD5 checksum of some content. How do I do this in PowerShell?

17条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 01:44

    As stated in the accepted answer, Get-FileHash is easy to use with files, but it is also possible to use it with strings:

    $s = "asdf"
    Get-FileHash -InputStream ([System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($s)))
    

提交回复
热议问题