Skip to content

Instantly share code, notes, and snippets.

@pcrockett-pathway
Last active November 26, 2018 09:25
Show Gist options
  • Select an option

  • Save pcrockett-pathway/3832925ad1ed97bbc208dd4d7388dd1d to your computer and use it in GitHub Desktop.

Select an option

Save pcrockett-pathway/3832925ad1ed97bbc208dd4d7388dd1d to your computer and use it in GitHub Desktop.
Hashes the contents of your clipboard
[CmdletBinding()]
param(
[Parameter()]
[string]$Algorithm = "SHA1",
[Parameter()]
[Text.Encoding]$Encoding = [Text.Encoding]::UTF8
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 5.0
$buffer = $Encoding.GetBytes((Get-Clipboard))
$stream = [IO.MemoryStream]::new($buffer)
try {
Get-FileHash -Algorithm $Algorithm -InputStream $stream | Select-Object Algorithm, Hash
}
finally {
$stream.Close()
$stream.Dispose()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment