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

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)

posted @ 2020-09-03 11:41  大树2  阅读(694)  评论(0编辑  收藏  举报