I'm attempting to encrypt an ID for use as parameters in Vue.js using Crypto-JS, but I keep encountering the error message: Cannot read property 'HmacSHA256' of undefined. I ran into the same issue when trying ASE and MD5. What am I doing wrong? Below is my code:
//in main.js
import CryptoJS from 'crypto-js'
Vue.use(CryptoJS)
//in my component
goToEvent (singleEvent) {
const id = this.CryptoJS.HmacSHA256(singleEvent.id, 'mySecretKey').toString(this.CryptoJS.enc.Hex)
this.$store.commit('SET_SELECTED_EVENT', singleEvent)
this.$router.push(`/admin/events/event/${id}`)
}