js base64编码,C#解码

   JS:

  

        this.Base64 = function (str) {
            return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
                return String.fromCharCode('0x' + p1);
            }));
        }

  C#:

  

        public static string UnBase64String(string value)
        {
            if (value == null || value == "")
            {
                return "";
            }
            byte[] bytes = Convert.FromBase64String(value);
            return Encoding.UTF8.GetString(bytes);
        }

 

posted @ 2019-07-01 16:38  顾星河  阅读(732)  评论(0编辑  收藏  举报