angularjs - How to independence inject Browserify Crypto in Angular Ionic -


i new bee of ionic , angular. used browserify require crypto module of nodejs ionic project. following steps:

  1. i added new line app.js file

angular.module(.....).constant('crypto',require('crypto'))

  1. i run command line, create new file code of crypto module , app.js file

browserify app.js > bundle.js

  1. i replace app.js bundle.js in index.html file

  2. i try test in service.js

angular.module('mapp.services').factory('abc',['$http','crypto',function($http,crypto){
return {
getallproduct:function(){ console.log(crypto.sha256("message")); });
} }]);

it return message "crypto.sha256 not function". think "constant" means value, not static object, cannot pass crypto "constant". so, how can require needed modules @ app.js file browserify , pass use @ other js file, $http? thanks!

sorry because of stupid question. fact can assign crypto object constant pool. problem code. encrypt string, code must be

crypto.createhash('sha256').update(mystr).digest('base64');

instead of

crypto.sha256(mystr)

now problem solved, reply , comments.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -