Answers for "how to encode and decode a string in c#"

C#
0

how to encode and decode a string in c#

public static string encode(string text)
{
    byte[] mybyte = System.Text.Encoding.UTF8.GetBytes(text);
    string returntext = System.Convert.ToBase64String(mybyte);
    return returntext;
}

public static string decode(string text)
{
    byte[] mybyte = System.Convert.FromBase64String(text);
    string returntext = System.Text.Encoding.UTF8.GetString(mybyte);
    return returntext;
}
Posted by: Guest on July-01-2021

Code answers related to "how to encode and decode a string in c#"

C# Answers by Framework

Browse Popular Code Answers by Language