Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AES encryption with Protect/Unprotect-CString adds null bytes to decrypted string #87

Closed
decoyjoe opened this issue Nov 17, 2020 · 0 comments
Assignees

Comments

@decoyjoe
Copy link
Member

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
@decoyjoe decoyjoe self-assigned this Nov 17, 2020
decoyjoe added a commit that referenced this issue Nov 18, 2020
…on-cstring-null-bytes

Fix #87 Unprotect-CString adds extra null bytes to the decrypted string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant