Skip to content

Instantly share code, notes, and snippets.

@pronichkin
Created June 5, 2021 20:35
Show Gist options
  • Save pronichkin/40b4434bff8bc47a262751d670a244e7 to your computer and use it in GitHub Desktop.
Save pronichkin/40b4434bff8bc47a262751d670a244e7 to your computer and use it in GitHub Desktop.
$String = 'Narrator.exe'
$MemoryStream = [System.IO.MemoryStream]::new()
$StreamWriter = [System.IO.StreamWriter]::new( $MemoryStream )
$StreamWriter.write( $String )
$StreamWriter.Flush()
$MemoryStream.Position = 0
$Hash = Get-FileHash -InputStream $MemoryStream -Algorithm 'SHA1'
$HexString = '0x' +
$Hash.Hash.Substring( 6, 2 ) +
$Hash.Hash.Substring( 4, 2 ) +
$Hash.Hash.Substring( 2, 2 ) +
$Hash.Hash.Substring( 0, 2 )
[System.uInt32]$HexString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment