Created
October 31, 2020 21:10
-
-
Save Israel-Miles/cf179cbe3b1ac61b833a69f34448c7db to your computer and use it in GitHub Desktop.
aes service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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