Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
vue-cryptojs
Advanced tools
Readme
A small wrapper for integrating crypto-js into Vue3 and Vue2
npm install vue-cryptojs
Entry file:
import { createApp } from 'vue'
import VueCryptojs from 'vue-cryptojs'
createApp(...).use(VueCryptojs).mount(...)
TS Component:
<script setup lang="ts">
import { inject } from 'vue'
import CryptoJS from 'crypto-js'
const cryptojs = inject('cryptojs') as typeof CryptoJS
</script>
<template>
<p>{{cryptojs.AES.encrypt("Hi There!", "Secret Passphrase").toString()}}</p>
<p>{{cryptojs.AES.decrypt("U2FsdGVkX1/zclTGSirKJ+oYxGJFRR96i9MkjOb8X0s=", "Secret Passphrase").toString(cryptojs.enc.Utf8)}}</p>
</template>
inject
on Composition API without TS:
<script>
import { inject } from 'vue'
export default {
setup() {
const cryoptojs = inject('cryptojs')
return {
cryoptojs
}
}
}
</script>
import Vue from 'vue'
import VueCryptojs from 'vue-cryptojs'
Vue.use(VueCryptojs)
This binds CryptoJS
to Vue
or this
if you're using single file component.
Simple AES text encrypt/decrypt example:
const encryptedText = this.$CryptoJS.AES.encrypt("Hi There!", "Secret Passphrase").toString()
const decryptedText = this.$CryptoJS.AES.decrypt(encryptedText, "Secret Passphrase").toString(this.$CryptoJS.enc.Utf8)
Directly on a template:
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3 + Vite" />
{{ $CryptoJS.AES.encrypt("Hi There!", "Secret Passphrase").toString() }}
</template>
Please kindly check full documention of crypto-js
FAQs
A small wrapper for integrating crypto-js into VueJS
The npm package vue-cryptojs receives a total of 3,575 weekly downloads. As such, vue-cryptojs popularity was classified as popular.
We found that vue-cryptojs demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.