Advertisement
kidto1412

crypto

Jun 30th, 2024
1,320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import CryptoJS from 'crypto-js'
  2.  
  3. const uuid = require('device-uuid')
  4. const keyAccess = uuid.DeviceUUID().get()
  5.  
  6. export default {
  7.   encryption: function (data: string) {
  8.     try {
  9.       if (data == null) {
  10.         return null
  11.       } else {
  12.         const enkripsi = CryptoJS.AES.encrypt(data, keyAccess).toString()
  13.         return enkripsi
  14.       }
  15.     } catch (error) {
  16.       console.log(error)
  17.       return null
  18.     }
  19.   },
  20.   dencrytion: function (data: null) {
  21.     try {
  22.       if (data == null) {
  23.         return null
  24.       } else {
  25.         const bytes = CryptoJS.AES.decrypt(data!, keyAccess)
  26.         const terjemaah = bytes.toString(CryptoJS.enc.Utf8)
  27.         return terjemaah
  28.       }
  29.     } catch (error) {
  30.       console.log(error)
  31.       return null
  32.     }
  33.   },
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement