From 2f874fa4d2bd9a80ef4610f46c5f206a3f6b5385 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 10 Sep 2019 09:38:35 +0200 Subject: [PATCH] Added Tool-Function to get Sha1 from String elements --- lib/core/tools/Get-StringSha1.psm1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/core/tools/Get-StringSha1.psm1 diff --git a/lib/core/tools/Get-StringSha1.psm1 b/lib/core/tools/Get-StringSha1.psm1 new file mode 100644 index 0000000..cbaad28 --- /dev/null +++ b/lib/core/tools/Get-StringSha1.psm1 @@ -0,0 +1,17 @@ +function Get-StringSha1() +{ + param( + [string]$Content + ); + + $CryptoAlgorithm = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider; + $ContentHash = [System.Text.Encoding]::UTF8.GetBytes($Content); + $ContentBytes = $CryptoAlgorithm.ComputeHash($ContentHash); + $OutputHash = ''; + + foreach($byte in $ContentBytes) { + $OutputHash += $byte.ToString() + } + + return $OutputHash; +}