Wednesday, September 28, 2022
HomePowershellDecrypt a Safe String – SID-500.COM

Decrypt a Safe String – SID-500.COM


PowerShell

On this weblog submit I’ll perform the way to decrypt a safe string. A safe string is a string that’s saved in a non-readable format to briefly retailer passwords and strings. Let’s begin.

For testing functions, retailer a password as a safe string.

$password = ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Pressure

Subsequent, we’ll use a considerably cryptic code to decrypt this.

$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($password)
$outcome = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr)

Right here is your entire code in motion:

Nice that’s it.

Printed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Marketing consultant, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments