AES encryption with Protect/Unprotect-CString adds null bytes to decrypted string
Closed this issue · 0 comments
decoyjoe commented
When encrypting and then decrypting a string with Protect-CString
/Unprotect-CString
via a -Key
(i.e. AES encryption), the resulting decrypted string contains null bytes at the end.
Current behavior:
> $key = '1' * 16
> $result = 'a' | Protect-CString -Key $key | Unprotect-CString -Key $key
> $result.length
16
> [System.Text.Encoding]::UTF8.GetBytes($result)
97
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Expected behavior:
> $key = '1' * 16
> $result = 'a' | Protect-CString -Key $key | Unprotect-CString -Key $key
> $result.length
1
> [System.Text.Encoding]::UTF8.GetBytes($result)
97