Skip to content

giampierod/Get-StringHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

Compute the hash value for a string by using a specific hash algorithm.

DESCRIPTION

The Get-StringHash script computes the hash value for a string by using a specified hash algorithm. A hash value is a unique value that corresponds to the content of the string.

By default, the Get-StringHash script uses the SHA256 algorithm, although any hash algorithm that is supported by the target operating system can be used.

Parameter: Algorithm

Specifies the cryptographic hash function to use for computing the hash value of the contents of the specified file. A cryptographic hash function includes the property that it is not possible to find two distinct inputs that generate the same hash values. Hash functions are commonly used with digital signatures and for data integrity. The acceptable values for this parameter are:

  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • MD5

If no value is specified, or if the parameter is omitted, the default value is SHA256.

Parameter: String

Specifies the string that is to be hashed.

OUTPUTS

StringHashInfo

Get-StringHash returns an object that represents the string that was hashed, the value of the computed hash, and the algorithm used to compute the hash.

EXAMPLE 1

    Get-StringHash.ps1 -String "HashThisString" | Format-List

    Hash         : BE767EABA134CB2F01E8D1755A8DD3B18BC8B063049CFF5E6228F5F7143FF777
    Algorithm    : SHA256
    SourceString : HashThisString

EXAMPLE 2

    "PipelineString" | Get-StringHash.ps1 | Format-List

    Hash         : 26F5E3BDA4FED8F257BD76B4653CB3D49FE572031891DE74E532E6AE088FE892
    Algorithm    : SHA256
    SourceString : PipelineString

EXAMPLE 3

    Get-StringHash.ps1 -String "UseMD5" -Algorithm MD5 | Format-List

    Hash         : 1634763BFA8CFCB2C795A05B894554CA
    Algorithm    : MD5
    SourceString : UseMD5

About

A script for getting a hash from a string in PowerShell that works on PowerShell Core.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published