public static string EncryptString(string toEncode) { try { byte[] toEncodeAsBytes = Encoding.UTF8.GetBytes(toEncode); return Convert.ToBase64String(toEncodeAsBytes); } catch (Exception ex) { //do your error handling here } } public static string DecryptString(string toDecrypt) { try { byte[] encodedDataAsBytes = Convert.FromBase64String(toDecrypt.Replace(" ", "+")); return Encoding.UTF8.GetString(encodedDataAsBytes); } catch (Exception ex) { //do your error handling here } }
You can apply some other encryption algorithms like TripleDES before applying the Base64 encoding.
PS: Be careful of the URL length restriction.
No comments:
Post a Comment