ConvertFrom-EncryptedData.ps1

Function ConvertFrom-EncryptedData {
    
    [CmdletBinding()]
    Param (
        [Byte[]]$Key,
        
        [String]$TextInput
    )

    #Decrypt the text input with the secret key.
    $Result = $TextInput | 
        ConvertTo-SecureString -Key $Key | 
        ForEach-Object {
            [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($_))
        };

    #Return the decrypted data.
    Return $Result;
}