Jan. 30, 2024, 7:50 a.m. | Anil Singh

DEV Community dev.to

Step 1:


First, let's install crypto-js in our Angular project using npm:


npm install crypto-js

npm i --save-dev @types/crypto-js


Step 2:


Once crypto-js is installed, we can import it into our Local Service (EncrDecrService):


import * as CryptoJS from 'crypto-js';


Step 3:


Now we will add two encrypt and decrypt methods to handle encryption and decryption in our service class:


Step 4:

//Private Key



key = "encrypt!135790";



//To encrypt input data
public encrypt(password: string): string {
return CryptoJS.AES.encrypt(password, this.key).toString();
} …

angular can crypto data dev import install local npm project react service tutorial types

Senior Security Specialist, Forsah Technical and Vocational Education and Training (Forsah TVET) (NEW)

@ IREX | Ramallah, West Bank, Palestinian National Authority

Consultant(e) Junior Cybersécurité

@ Sia Partners | Paris, France

Senior Network Security Engineer

@ NielsenIQ | Mexico City, Mexico

Senior Consultant, Payment Intelligence

@ Visa | Washington, DC, United States

Corporate Counsel, Compliance

@ Okta | San Francisco, CA; Bellevue, WA; Chicago, IL; New York City; Washington, DC; Austin, TX

Security Operations Engineer

@ Samsara | Remote - US