Skip to content

Instantly share code, notes, and snippets.

@ohmpzz
Created April 29, 2018 15:47
Show Gist options
  • Save ohmpzz/6dfee093cdeb6e6b89ab1c1bf8c207ff to your computer and use it in GitHub Desktop.
Save ohmpzz/6dfee093cdeb6e6b89ab1c1bf8c207ff to your computer and use it in GitHub Desktop.
decrypt(data) {
const ciphertext = data.msg
const key = this.chatService.getPasscode
const bytes = CryptoJS.AES.decrypt(ciphertext, key)
const plaintext = bytes.toString(CryptoJS.enc.Utf8)
console.log(data.msg)
console.log(key)
console.log(bytes.toString(CryptoJS.enc.Utf8))
return {msg: plaintext}
}
encrypt(msg: string) {
const plaintext = msg
const key = this.chatService.getPasscode
const ciphertext = CryptoJS.AES.encrypt(plaintext, key)
console.log(msg)
console.log(key)
return ciphertext.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment