Can I use sha256 function in Ionic?

It looks like the library is actually deprecated.

I’ve found another library that implements sha-256,

https://www.npmjs.com/package/jssha

npm install jssha --save
npm install @types/jssha --save-dev
import { Component } from '@angular/core';
import jsSHA from 'jssha'
import { NavController } from 'ionic-angular';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
    let shaObj = new jsSHA("SHA-256", "TEXT");
    shaObj.update("This is a test");
    let hash = shaObj.getHash("HEX");
    console.log(hash)
  }
}
4 Likes