C#encode encryption, JS decode decryption

/// <summary> /// Base64 encryption, encrypted with utf8 encoding /// </summary> /// <param name="source">clear text to be encrypted</param> /// <returns>Encrypted string</returns> Public static string Base64Encode(string source) { Return Base64Encode(Encoding.UTF8, source); } /// <summary> /// Base64 encryption /// </summary> /// <param name="encodeType">Encoding method used for encryption</param> /// <param name="source">clear text to be encrypted</param> /// <returns></returns> Public static string Base64Encode(Encoding encodeType, string source) { String encode = string.Empty; Byte[] bytes = encodeType.GetBytes(source); Try { Encode = Convert.ToBase64String(bytes); } Catch { Encode = source; } Return encode;

        }

JS

var b = new Base64();
        Var str = b.encode("admin:admin");
        Alert("base64 encode:" + str);
//decrypt
        Str = b.decode(str);
        Alert("base64 decode:" + str);