VUE 前端调用Base64加密,后端c#调用Base64解密

vue

VUE 前端调用Base64加密,后端c#调用Base64解密
1.安装js-base64 运行依赖
2. 方法中引用:
let Base64 = require('js-base64').Base64
var passwordBase64=Base64.encode(this.loginForm.password);
params.append('password', passwordBase64);

c#中解密:
string newPassword = this.DecodeBase64("utf-8", passWord);

public static string DecodeBase64(string code_type, string code)
{
string decode = "";
byte[] bytes = Convert.FromBase64String(code);
try
{
decode = Encoding.GetEncoding(code_type).GetString(bytes);
}
catch
{
decode = code;
}
return decode;
}

二.vue中url字符转码
1.安装encode-uri 运行依赖
2.main.js 引用:
import EncodeURL from 'encode-uri'

Vue.prototype.$encodeURL = EncodeURL
3.代码中使用:
var encode = this.$encodeURL(urlstring)
var newurl = this.$decodeURI(encode)

以上是 VUE 前端调用Base64加密,后端c#调用Base64解密 的全部内容, 来源链接: utcz.com/z/379927.html

回到顶部