Identity icon indicating copy to clipboard operation
Identity copied to clipboard

Encrypting string

Open john2014 opened this issue 9 years ago • 1 comments

Hi, I am not sure which is the correct repository to post this to. I apologize if this is not the correct one.

Goal: Create a function to encrypt and decrypt string using Asp.net Core and System.Security.Cryptography

Solution: The nearest match I found was this url: http://mikaelkoskinen.net/post/encrypt-decrypt-string-asp-net-core

However when I run this I immediately get an error message "Padding is invalid and cannot be removed."

After searching a lot in google, I added "aesAlg.Padding = PaddingMode.Zeros;" in the DecryptString() function. That kinda worked.

Input String "this is secret text Example test" Encrypted String: B7w3aKWTZwpy8UhxI7Ea8BvLcVDh48C9SqHv............ Decrypted string: this is secret t

The decrypted string is truncated after 12 characters and I have no idea why its happening. Am I missing something or is it bug in the Crypto library? Thank you 😄

john2014 avatar Jul 07 '17 00:07 john2014

This is not the correct repo, not is it a source question. Honestly you'd be better off asking on Stack Overflow for general use questions like this.

blowdart avatar Jul 12 '17 19:07 blowdart