refactor: adapt to nuspec requirement for gallery publishing
This commit is contained in:
parent
2019f8c959
commit
69c2684ee7
29 changed files with 84 additions and 20 deletions
42
tools/String.psm1
Executable file
42
tools/String.psm1
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env pwsh
|
||||
|
||||
function Get-StringHash
|
||||
{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Get hash value of a string
|
||||
|
||||
.DESCRIPTION
|
||||
The Get-StringHash function is just a wrapper around the
|
||||
Get-FileHash function and utilizes a stream for providing said
|
||||
function with proper input values.
|
||||
|
||||
.OUTPUTS
|
||||
Same as the Get-FileHash function
|
||||
|
||||
.EXAMPLE
|
||||
Get-StringHash 'foobar' -Algorithm 'SHA256'
|
||||
#>
|
||||
Param(
|
||||
[Parameter(Mandatory, Position = 0)] [String] $InputString,
|
||||
[Parameter()] [String] $Algorithm = 'SHA256'
|
||||
)
|
||||
|
||||
Begin
|
||||
{
|
||||
$stream = [IO.MemoryStream]::New()
|
||||
|
||||
$writer = [IO.StreamWriter]::New($stream)
|
||||
|
||||
$writer.Write($InputString)
|
||||
|
||||
$writer.Flush()
|
||||
|
||||
$stream.Position = 0
|
||||
}
|
||||
|
||||
Process
|
||||
{
|
||||
Get-FileHash -InputStream $stream -Algorithm $Algorithm
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue