Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import CryptoJS from 'crypto-js'
- const uuid = require('device-uuid')
- const keyAccess = uuid.DeviceUUID().get()
- export default {
- encryption: function (data: string) {
- try {
- if (data == null) {
- return null
- } else {
- const enkripsi = CryptoJS.AES.encrypt(data, keyAccess).toString()
- return enkripsi
- }
- } catch (error) {
- console.log(error)
- return null
- }
- },
- dencrytion: function (data: null) {
- try {
- if (data == null) {
- return null
- } else {
- const bytes = CryptoJS.AES.decrypt(data!, keyAccess)
- const terjemaah = bytes.toString(CryptoJS.enc.Utf8)
- return terjemaah
- }
- } catch (error) {
- console.log(error)
- return null
- }
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement