vue-cryptojs
Advanced tools
Comparing version 2.1.6 to 2.2.0
@@ -15,16 +15,28 @@ "use strict"; | ||
install: function install(Vue, options) { | ||
Vue.CryptoJS = _cryptoJs["default"]; | ||
Object.defineProperties(Vue.prototype, { | ||
CryptoJS: { | ||
get: function get() { | ||
return _cryptoJs["default"]; | ||
Vue.CryptoJS = _cryptoJs["default"]; // VueJS 2 | ||
if (Vue.prototype) { | ||
Object.defineProperties(Vue.prototype, { | ||
$CryptoJS: { | ||
get: function get() { | ||
return _cryptoJs["default"]; | ||
} | ||
}, | ||
CryptoJS: { | ||
get: function get() { | ||
return _cryptoJs["default"]; | ||
} | ||
} | ||
}, | ||
$CryptoJS: { | ||
get: function get() { | ||
return _cryptoJs["default"]; | ||
} | ||
} | ||
}); | ||
}); | ||
} // VueJS 3 | ||
if (Vue.config && Vue.config.globalProperties) { | ||
Vue.config.globalProperties.$CryptoJS = _cryptoJs["default"]; | ||
} | ||
if (Vue.provide && typeof Vue.provide === 'function') { | ||
Vue.provide('cryptojs', _cryptoJs["default"]); | ||
} | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
@@ -31,0 +43,0 @@ window.Vue.use(VueCryptojs); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _cryptoJs=_interopRequireDefault(require("crypto-js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var VueCryptojs={install:function(e,t){e.CryptoJS=_cryptoJs.default,Object.defineProperties(e.prototype,{CryptoJS:{get:function(){return _cryptoJs.default}},$CryptoJS:{get:function(){return _cryptoJs.default}}}),"undefined"!=typeof window&&window.Vue&&window.Vue.use(VueCryptojs)}},_default=VueCryptojs;exports.default=_default; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _cryptoJs=_interopRequireDefault(require("crypto-js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var VueCryptojs={install:function(e,t){e.CryptoJS=_cryptoJs.default,e.prototype&&Object.defineProperties(e.prototype,{$CryptoJS:{get:function(){return _cryptoJs.default}},CryptoJS:{get:function(){return _cryptoJs.default}}}),e.config&&e.config.globalProperties&&(e.config.globalProperties.$CryptoJS=_cryptoJs.default),e.provide&&"function"==typeof e.provide&&e.provide("cryptojs",_cryptoJs.default),"undefined"!=typeof window&&window.Vue&&window.Vue.use(VueCryptojs)}},_default=VueCryptojs;exports.default=_default; |
{ | ||
"name": "vue-cryptojs", | ||
"version": "2.1.6", | ||
"version": "2.2.0", | ||
"description": "A small wrapper for integrating crypto-js into VueJS", | ||
@@ -30,3 +30,3 @@ "main": "dist/vue-cryptojs.min.js", | ||
"@babel/preset-env": "^7.10.4", | ||
"gulp": "^4.0.0", | ||
"gulp": "^4.0.2", | ||
"gulp-babel": "^8.0.0", | ||
@@ -33,0 +33,0 @@ "gulp-rename": "^1.2.2", |
# vue-cryptojs | ||
A small wrapper for integrating crypto-js into VueJS | ||
A small wrapper for integrating crypto-js into Vue3 and Vue2 | ||
@@ -11,2 +11,11 @@ ## How to install: | ||
```js | ||
// Vue3 | ||
import { createApp } from 'vue' | ||
import VueCryptojs from 'vue-cryptojs' | ||
const app = createApp(...) | ||
app.use(VueCryptojs) | ||
app.mount('#app') | ||
// Vue2 | ||
import Vue from 'vue' | ||
@@ -22,13 +31,24 @@ import VueCryptojs from 'vue-cryptojs' | ||
```js | ||
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) | ||
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) | ||
``` | ||
Also `crypto-js` is available as: | ||
For Vue3 we suggest to use `inject` on Composition API: | ||
```js | ||
Vue.CryptoJS | ||
this.CryptoJS | ||
this.$CryptoJS | ||
<script> | ||
import { inject } from 'vue' | ||
export default { | ||
setup() { | ||
const cryoptojs = inject('cryptojs') | ||
return { | ||
cryoptojs | ||
} | ||
} | ||
} | ||
</script> | ||
``` | ||
Please kindly check full documention of [crypto-js](https://github.com/brix/crypto-js) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5842
88
53