forked from arkan/angular-cryptography
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdo-angular-cryptography.js
More file actions
32 lines (24 loc) · 890 Bytes
/
mdo-angular-cryptography.js
File metadata and controls
32 lines (24 loc) · 890 Bytes
1
2
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
29
30
31
32
angular.module('mdo-angular-cryptography', [])
.provider('$crypto', function CryptoKeyProvider() {
var cryptoKey;
this.setCryptographyKey = function(value) {
this.cryptoKey = value;
}
this.$get = [function(){
return {
cryptoKey: this.cryptoKey,
encrypt: function(message, key) {
if (key === undefined) {
key = this.cryptoKey;
}
return CryptoJS.AES.encrypt(message, key ).toString();
},
decrypt: function(message, key) {
if (key === undefined) {
key = this.cryptoKey;
}
return CryptoJS.AES.decrypt(message, key).toString(CryptoJS.enc.Utf8)
}
}
}];
});