在Angular.js中加密ID

时间:2019-01-31 07:11:36

标签: angular-ui-router

$ rootScope.encrypt不是函数     在Controller.js:23

这是我的.js文件

.run(function(cfCryptoHttpInterceptor, $rootScope) {
        $rootScope.base64Key = CryptoJS.enc.Base64.parse("2b7e151628aed2a6abf7158809cf4f3c");
      $rootScope.iv = CryptoJS.enc.Base64.parse("3ad77bb40d7a3660a89ecaf32466ef97");
      $rootScope.encrypt = function(string)
      {

          var encrypted = CryptoJS.AES.encrypt(
                    string,
                    $rootScope.base64Key,
                    { iv: $rootScope.iv });
                     return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
      }}

我的控制器迷糊糊

 angular.forEach($scope.alluserdata,function(value,key)
      {
         value.mst_tbl_user_id = $rootScope.encrypt("'"+value.mst_tbl_user_id+"'");
         console.log(value.mst_tbl_user_id)
      });

0 个答案:

没有答案