mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added SecureString convertion functions
This commit is contained in:
parent
64410ea00a
commit
317c42daef
2 changed files with 25 additions and 0 deletions
13
lib/core/tools/ConvertFrom-IcingaSecureString.psm1
Normal file
13
lib/core/tools/ConvertFrom-IcingaSecureString.psm1
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function ConvertFrom-IcingaSecureString()
|
||||
{
|
||||
param([SecureString]$SecureString);
|
||||
|
||||
if ($SecureString -eq $null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
[IntPtr]$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
|
||||
[string]$String = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
|
||||
|
||||
return $String;
|
||||
}
|
||||
12
lib/core/tools/ConvertTo-IcingaSecureString.psm1
Normal file
12
lib/core/tools/ConvertTo-IcingaSecureString.psm1
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<#
|
||||
# Helper class allowing to easily convert strings into SecureStrings
|
||||
# and vice-versa
|
||||
#>
|
||||
function ConvertTo-IcingaSecureString()
|
||||
{
|
||||
param(
|
||||
[string]$String
|
||||
);
|
||||
|
||||
return (ConvertTo-SecureString -AsPlainText $string -Force);
|
||||
}
|
||||
Loading…
Reference in a new issue