1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$unencryptedString = "This is my plain text" # Cifrar $bytes = [System.Text.Encoding]::UTF8.GetBytes($unencryptedString) $aesManaged = New-Object "System.Security.Cryptography.AesManaged" $aesManaged.Mode = [System.Security.Cryptography.CipherMode]::ECB $aesManaged.BlockSize = 128 $aesManaged.Key = [System.Text.Encoding]::UTF8.GetBytes('This is my secre') $encryptor = $aesManaged.CreateEncryptor() $encryptedData = $encryptor.TransformFinalBlock($bytes, 0, $bytes.Length); $encrypted = [System.Convert]::ToBase64String($encryptedData) $encrypted |