How to implement SHA-256 encryption in Angular2

angular, javascript, sha256

Solution

I used sha.js for this purpose, it is so simple and does the trick!

First `npm install --save sha.js`

Import in your component, service, etc... :

import * as shajs from 'sha.js';

And then use it as the docs suggests:

shajs('sha256').update({stringToBeHashed}).digest('hex')

Problem

I need to encrypt my password in SHA256 before making API request . I am not able to find any implementation of SHA-256 in Angular2

Original source