how to generate md5 hash in angular 2 typescript?

前端 未结 2 467
臣服心动
臣服心动 2020-12-30 02:03

I am using APi The access to this api is done with hash key that we need to send to the api but we don\'t really know how to implement.

I found https://www.npmjs.co

相关标签:
2条回答
  • 2020-12-30 02:25

    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);
    
    0 讨论(0)
  • 2020-12-30 02:42

    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.

    0 讨论(0)
提交回复
热议问题