Blame view

public/js/services/EncryptServ.js 900 Bytes
20a0d553   Geoffrey PREUD'HOMME   Il parait que les...
1
2
  angular.module('EncryptServ', [])
      .service('EncryptServ', function ($http) {
2f593328   Geoffrey PREUD'HOMME   Linting
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
          a = {
              encrypter: false,
              whenOk: function (cb) {
                  if (this.encrypter) {
                      cb();
                  } else {
                      this.prepare(cb);
                  }
              },
              prepare: function (cb) {
                  $http.get('/com/ci_com_pub.pem').success(function (key) {
                      this.encrypter = new JSEncrypt();
                      this.encrypter.setPublicKey(key);
                      cb();
                  });
              },
              preload: function (cb) {
                  this.whenOk(cb);
              },
              encrypt: function (string, cb) {
                  this.whenOk(function () {
                      cb(this.encrypter.encrypt(string));
                  });
              }
          };
          return a;
20a0d553   Geoffrey PREUD'HOMME   Il parait que les...
29
      });