How do I encode and decode a base64 string?

前端 未结 10 2271
我在风中等你
我在风中等你 2020-11-22 03:41
  1. How do I return a base64 encoded string given a string?

  2. How do I decode a base64 encoded string into a string?

10条回答
  •  甜味超标
    2020-11-22 04:09

    You can use below routine to convert string to base64 format

    public static string ToBase64(string s)
    {
        byte[] buffer = System.Text.Encoding.Unicode.GetBytes(s);
        return System.Convert.ToBase64String(buffer);
    }
    

    Also you can use very good online tool OnlineUtility.in to encode string in base64 format

提交回复
热议问题