0

Encryption and decryption with ascii

How can you encrypt and decrypt a string using for loop and ascii code in c#?

6th Nov 2018, 8:11 PM
Huzafa Suhail
Huzafa Suhail - avatar
8 Antworten
+ 1
You can add some number to every characters ascii code so it makes unreadable text. Like if you add 1, "hi" becomes "ij" But it can be easy, so you can use the byte information and play with it, just be sure undoing the code results in unique output for a unique input.
7th Nov 2018, 2:56 AM
Gaurav Atreya
Gaurav Atreya - avatar
0
I just need to encrypt a specific given string and decrypt that encrypted string. Thanks btw 😊
7th Nov 2018, 7:07 AM
Huzafa Suhail
Huzafa Suhail - avatar
0
I have enrypted the string by changing ascii values of the characters in string. but now i am in confusion of how to decrypt the new value to its old form.
7th Nov 2018, 7:48 PM
Huzafa Suhail
Huzafa Suhail - avatar
0
How did you change the ascii value? If you linearly added or subtacted a value do the opposite.
8th Nov 2018, 2:00 AM
Gaurav Atreya
Gaurav Atreya - avatar
0
Console.WritLine("Enter Your String: "); string s = Console.ReadLine(); foreach(char c in s) {        Console.Write((int)c+2); }        Console.ReadKey();
8th Nov 2018, 2:39 AM
Huzafa Suhail
Huzafa Suhail - avatar
0
Now it is giving me output of 718885
8th Nov 2018, 2:40 AM
Huzafa Suhail
Huzafa Suhail - avatar
0
Now i want to enter these ascii codes in the input and convert them back to the input i have entered before which is EVS
8th Nov 2018, 2:43 AM
Huzafa Suhail
Huzafa Suhail - avatar
0
Don't return integers convert, (int)c+2 into a character again, like (char)((int)c+2) , I'm not sure if (char) works but you got the jist. Then while decryption you do -2 instead of +2 and keep everything else same
8th Nov 2018, 8:38 AM
Gaurav Atreya
Gaurav Atreya - avatar