1.0.3 • Published 2 years ago

vue-crypto-yh v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

vue-crypto-yh

在开发项目内直接使用已封装好的加密解密方法

vue-crypto-yh 项目

# 本地项目
npm install

# 运行
npm run dev

# 发布正式
npm run build

# 登录npm
npm login

# 上传至npm
npm publish

(每次发布的时候packa.json 里面的 version不能一样,不然不能发布出去,可手动修改下版本即可)

在开发项目内使用步骤

1、加载vue-crypto-yh

执行 npm install vue-crypto-yh

2、在main.js内引入,格式如下:

//加密解密插件
import aesCrypto from 'vue-crypto-yh';
Vue.prototype.aesCrypto = aesCrypto;

3、在需要加密解密代码处调用,示例如下:

const appkey = 'xxxx'; // appkey必传
const key = 'xxxxxxxxxxxxxxxxxxxxxx'; // 密钥key必传:唯一指定的密钥,加密解密的密钥要保持一致。
const msg = {ret:0,msg: '查询成功'}; // 示例需要进行加密的明文数据
const content = JSON.stringify(msg); // 将明文数据转换为字符串
this.aesCrypto.constructor(appkey,key); // 必需
this.data = this.aesCrypto.encrypt(content);// 对数据进行加密,this.data打印就是加密后的密文

/**解密方法
 参数格式:
    {
      "signature":"结果签名",
      "timestamp":"时间戳,单位毫秒",
      "nonce":"随机字符串",
      "encrypt":"返回结果密文"
    }
*/
this.jiemi = this.aesCrypto.decrypt(this.data); // 对返回数据进行解密,this.jiemi打印就是解密后的明文数据
// JSON.parse(this.jiemi); 解密后的数据需要进行转换为对象数据
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago