The following code will help you to encrypt a string.
public string EncryptString(string strInput)
{
int i = 0;
string strTemp = null;
for (i = 0; i <= strInput.Length - 1; i++)
{
int charValue = Convert.ToInt32(strInput[i]); // converting in ascii
charValue ^= 30;
strTemp += char.ConvertFromUtf32(charValue);
}
return strTemp;
}
//Pass your string to this function and ‘strTemp’ will return the encrypted string.
Note: After encryption, we can use same function to decrypt a encrypted string.