How To Convert Values Into Sha-1 And Base64 In Javascript

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How To Convert Values Into Sha-1 And Base64 In Javascript



I want to convert these values into Sha-1 and after that I want to convert again into base64. I tried lots of methods. But , none of them work.


var nonce = 5;
var unixtm = 6;
var pw = '123';
var shapw = nonce+ ' + ' +unixtm+ ' + ' +pw; //5 + 6 + 123



I mean , First of all I want to convert 'shapw' into Sha-1 and after that convert into Base64. Here is the formula -



FinalPw = Base64 ( SHA-1 ( nonce + created + SHA-1 ( password ) ) )



How can I do this ??




1 Answer
1



There are a lot of libraries which could help you to create SHA1 hash. Here for example https://github.com/emn178/js-sha1. Install it and use like


sha1('Message to hash');
var hash = sha1.create();
hash.update('Message to hash');
hash.hex();



For base64 there are btoa() (to base64) and atob() (from base64) functions.


btoa()


atob()





It gives me this error - Uncaught ReferenceError: sha1 is not defined. How can I Fix this ?? I Insatlled Js-Sha1 using nodeJs.
– Amithash
Aug 13 at 9:07






read how to correctly install and use libraries using npm
– Vadzim Dvorak
Aug 13 at 14:45






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered