Encode and decode a string in C #

Hii, I had a requirement to encode a string provided in an unreadable format, and also perform decoding after performing certain actions. I tried the encoding "Base64". But this is not a safe way. I need other solutions. Give some help regarding the above context.

+3
source share
4 answers

You can use a symmetric encryption algorithm. Here is an example . Both parties (encryption / decryption) must share a common secret key for this.

+5
source

. #. , RijndaelManaged. . SQ

+2

See the following
http://www.codeproject.com/KB/cs/Cryptography.aspx
http://www.codeproject.com/KB/security/DotNetCrypto.aspx

Here is an example of using RSA. Replace your_rsa_key with the RSA key.

System.Security.Cryptography.RSACryptoServiceProvider Provider =
                new System.Security.Cryptography.RSACryptoServiceProvider();
Provider.ImportParameters(your_rsa_key);
byte[] encrypted = Provider.Encrypt(System.Text.Encoding.UTF8.GetBytes("Hello World!"), true);
string decrypted = System.Text.Encoding.UTF8.GetString(Provider.Decrypt(encrypted, true));
+2
source

Namespace System.Security.Cryptographycan help you. But when choosing an encryption algorithm, consider the size of the data you are trying to encrypt and the level of security that you want to achieve.

+1
source

Source: https://habr.com/ru/post/1742250/


All Articles