
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
vue3-encryption-plugin
Advanced tools
你的 Pinia 加密插件是一个基于 crypto-js 封装的实用hooks工具,用于在 Vue.js 应用程序中加密和解密敏感数据。它提供了一种简单且安全的方式来保护你的数据。
你可以使用 npm 或 yarn 安装插件:
pnpm i vue3-encryption-plugin
在你的主应用程序入口文件(例如 main.js)中,导入并使用 Pinia store 以及加密插件:
// main.js
import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import EncryptionPlugin from "vue3-encryption-plugin";
const app = createApp(App);
const pinia = createPinia();
app.use(pinia);
// 注册加密插件并提供自定义的密钥(可选)例如,随机的字符串
app.use(EncryptionPlugin, { key: "your-custom-secret-key" });
app.mount("#app");
一旦你设置了插件,你就可以在组件中使用 $encrypt 和 $decrypt 方法:
第一种: getCurrentInstance()
<!-- YourComponent.vue -->
import { getCurrentInstance } from 'vue';
setup(){
// 获取当前组件的上下文,下面两种方式都能获取到组件的上下文。
const { ctx } = getCurrentInstance(); // 方式一,这种方式只能在开发环境下使用,生产环境 下的ctx将访问不到
const { proxy }: any = getCurrentInstance(); // 方式二,此方法在开发环境以及生产环境下都能到组件上下文对象(推荐)
// ctx 中包含了组件中由ref和reactive创建的响应式数据对象,以及以下对象及方法;
proxy.$attrs
proxy.$data
proxy.$el
proxy.$emit
proxy.$forceUpdate
proxy.$nextTick
proxy.$options
proxy.$parent
proxy.$props
proxy.$refs
proxy.$root
proxy.$slots
proxy.$watch
}
function handClick() {
console.log(
"!这里输出 🚀 ==>:",
proxy.$encryptionPlugin.encryptData({ name: "zk", age: 26})
);
console.log(
"!这里输出 🚀 ==>:",
proxy.$encryptionPlugin.decryptData(
"U2FsdGVkX1/PBDHn2pyLPAf6DmolvylM2QEIDhcf5I3WQWhOh19eos0uZfdbzdDP"
)
);
}
第二种 injict (推荐)
1:src / types / global.d.ts 定义类型
// 加密解密
declare interface EncryptionPlugin {
encryptData: <T>(data: T) => string;
decryptData: <T>(encryptedData: string) => T;
}
如果你使用 eslint 请在 .eslintrc.cjs 文件中添加
globals: {
// 以下是全局变量 eslint 不会报'EncryptionPlugin' is not defined.eslint (no-undef)
EncryptionPlugin: "readonly",
$encryptionPlugin: "readonly",
},
2: 页面使用
<script setup lang="ts">
import { inject } from 'vue';
// 使用 inject 函数获取 encryptionPlugin
const encryptionPlugin = inject("encryptionPlugin") as EncryptionPlugin;
function handClick() {
// 现在你可以在你的组件中使用 encryptData 和 decryptData 方法了
const encryptedData = encryptionPlugin.encryptData("Hello World");
const decryptedData = encryptionPlugin.decryptData(encryptedData);
console.log("加密 🚀 ==>:", encryptedData);
console.log("解密 🚀 ==>:", decryptedData);
}
</script>
FAQs
✈️🔖🔖 pinia插件加密、实现本地数据加密解密
The npm package vue3-encryption-plugin receives a total of 2 weekly downloads. As such, vue3-encryption-plugin popularity was classified as not popular.
We found that vue3-encryption-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.