how to generate md5 hash in angular 2 typescript?

You can get a md5.ts file here:

https://github.com/ManvendraSK/angular2-quickstart/blob/master/app/md5.ts

import it in your component/service:

import {md5} from './md5'; //make sure it points to the folder where the md5.ts file is

then you can use it in your component/service:

let e = md5(this.email);

For angular 2 use

npm install ts-md5 --save

then import it into component, service or wherever you want

import {Md5} from 'ts-md5/dist/md5';

When you are using systemJS is neccessary set map and package paths.

 map:      {
              'ts-md5': 'src/js/ts-md5',
           },
 packages: {
              'ts-md5': {main: '/md5.js'},                
           }

This is the example from one of my project where I copy neccessary libraries to separate file structure.

Tags:

Angular