Encoding and Decoding in C#

How to encode and decode string in C# ,mvc.net 

By      09-Sep-2023    2



There are lot of techniques to handle this but here im going to use Base64 simple one. To convert string into Encoded string use below public static string EncodeBase64(string yourString) { var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); return System.Convert.ToBase64String(plainTextBytes); } To convert Encoded string into Base64Decode(string) use below. public static string DecodeBase64(string encodedDatabase64) { var base64EncodedBytes = System.Convert.FromBase64String(encodedDatabase64); return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); }

Your Answer