vue配置加密 vue 介面引數加密

2021-10-16 15:57:10 字數 1650 閱讀 4392

使用aes加密

新建crypto.js檔案 放在utils檔案中,掛在到vue原型鏈裡

npm install crypto-js

安裝 crypto-js

import cryptojs from 'crypto-js' //引用aes原始碼js

import cryptojs from 'crypto-js' //引用aes原始碼js

const key = cryptojs.enc.utf8.parse("-------"); //金鑰 密碼

const iv = cryptojs.enc.utf8.parse("-------");

const cryptoinfo = catch(exception e) return null;

}/*** 解密

*@paramcontent

*@return

public staticstring decrypt(string content) /*** 加密

*@paramcontent

* 需要加密的內容

*@paramkey

* 加密密碼

*@return

public static string encrypt(string data, string key) throw***ception byte plaintext = new byte[plaintextlength];

system.arraycopy(databytes,0, plaintext, 0, databytes.length);

secretkeyspec keyspec= new secretkeyspec(key.getbytes(), "aes");

ivparameterspec ivspec= newivparameterspec(key.getbytes());

cipher.init(cipher.encrypt_mode, keyspec, ivspec);byte encrypted =cipher.dofinal(plaintext);return newbase64().encodetostring(encrypted);

}catch(exception e) /*** aes(256)解密

*@paramcontent

* 待解密內容

*@paramkey

* 解密金鑰

*@return解密之後

*@throw***ception*/

public staticstring decrypt(string content, string key) catch(exception e) return null;

}public static void main(string args) throw***ception {

string s= "65de2594-9ace-e211-915e-00155d607702";//加密

system.out.println("加密前:" +s);

string encryptresultstr=encrypt(s);

system.out.println("加密後:" +encryptresultstr);//解密

system.out.println("解密後:" + decrypt("cehznznr6gqfgwahwuuoog=="));

vue 靜態引數 Vue 引數傳遞

一 父子元件 1.1父傳子 props 這裡是father元件 這是父元件要傳給子元件的引數 import child from child export default 接受的父元件靜態引數 接受的父元件引數 export default import child from child expor...

vue連線後端本地介面 詳解vue配置後台介面方式

在vueadmin專案中有兩種方式配置後端介面的方式,在此做下記錄 第一種 方式 在工程目錄下 config index.js 修改為如下配置 proxytable 第二種在工程目錄下 config dev.env.js 修改為如下 module.exports merge prodenv,node...

Vue 介面管理

在vue開發中,會涉及到很多介面的處理,當專案足夠大時,就需要定義規範統一的介面,如何定義呢?方法可能不只一種,本文使用axios async await進行介面的統一管理。本文使用vue cli生成的專案舉例。拿segmentfault的官網簡單舉個例子,先看一下官網 舉例問答模組 專欄模組 講堂...