Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Created October 31, 2020 21:10
Show Gist options
  • Save Israel-Miles/cf179cbe3b1ac61b833a69f34448c7db to your computer and use it in GitHub Desktop.
Save Israel-Miles/cf179cbe3b1ac61b833a69f34448c7db to your computer and use it in GitHub Desktop.
aes service
import { Injectable } from '@angular/core';
import * as CryptoJS from 'crypto-js';
@Injectable({
providedIn: 'root'
})
export class EncryptionService {
secretKey = "A secret key 123!";
constructor() { }
encrypt(value: string): string {
return CryptoJS.AES.encrypt(value, this.secretKey).toString();
}
decrypt(textToDecrypt: string) {
return CryptoJS.AES.decrypt(textToDecrypt, this.secretKey).toString(CryptoJS.enc.Utf8);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment