Angular: Encrypt | Decrypt
Using CryptoJS, tell me “I♥U”
Published in
1 min readJul 6, 2020
Tell me {{ 'U2F...3yeKpfg=' | decrypted }} // I♥U
Steps:
- Create
encrypted
/decrypted
pipes - Declare the pipes in your module
- Use it
1. Create encrypted /decrypted pipes
2. Declare the pipes in your module
import { EncryptPipe, DecryptPipe} from './encrypt-decrypt.pipe';@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent, EncryptPipe, DecryptPipe ],
providers: [ EncryptPipe, DecryptPipe ],
bootstrap: [ AppComponent ]
})export class AppModule { }
3. Use it
In html
<div>Encrypted : {{ secret | encrypted }}</div>
In component
constructor(encryptPipe: EncryptPipe) {
console.log('encrypted', encryptPipe.transform(this.secret))
}