-2

Should I use npm package like crypto-js ?

String hash = "Something" ;
hash = (new sun.misc.BASE64Encoder()).encode(sha.digest(hash.getBytes()));

Edit:

Suggestions led to different results. I have found the solution as below on server side with nodejs:

const crypto = require('crypto');
const hashStr = "Something different";
let sha = crypto.createHash('sha1');
sha.update(hashStr);
let shaBase64 = sha.digest('base64');

console.log(shaBase64);
Er.Se
  • 461
  • 3
  • 11

1 Answers1

0

You can use the window.btoa function for that.

btoa('Something');
Keimeno
  • 2,512
  • 1
  • 13
  • 34