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:
- i added new line app.js file
angular.module(.....).constant('crypto',require('crypto'))
- i run command line, create new file code of crypto module , app.js file
browserify app.js > bundle.js
i replace app.js bundle.js in index.html file
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
Post a Comment