AngularJS Module that integrate cryptography functionality offers from the crypto-js project. Provides a simple service to encrypt and decrypt using AES.
- AngularJS 1.1.4 + (tested with 1.1.4 and 1.2.16)
- Crypto-js 3.1.2 AES modul
##Install (bower)
- bower install angular-cryptography
<script type='text/javascript' src="[bower_components/]cryptojslib/rollups/aes.js"></script>
<script type='text/javascript' src="[bower_components/]angular-cryptography/mdo-angular-cryptography.js"></script>
##Install (manual)
<script type='text/javascript' src="js/aes.js"></script>
<script type='text/javascript' src="js/mdo-angular-cryptography.js"></script>
##Usage
- add module dependency ('mdo-angular-cryptography') to angular
var demoApp = angular.module('app', ['services', 'mdo-angular-cryptography']);
- setup the encryption key in your config
angular.module.('app').config(['$cryptoProvider', function($cryptoProvider){
$cryptoProvider.setCryptographyKey('ABCD123');
});
Example Service Usage
angular.module('app').controller('ExampleController', ['$scope', '$crypto', function($scope, $crypto) {
var encrypted = $crypto.encrypt('some plain text data');
var decrypted = $crypto.decrypt(encrypted);
});
or you can use a custom key everytime
angular.module('app').controller('ExampleController', ['$scope', '$crypto', function($scope, $crypto) {
var encrypted = $crypto.encrypt('some plain text data', 'some custom key');
var decrypted = $crypto.decrypt(encrypted, 'some other custom key');
});
That's all !
- Report at the github issue tracker
Middleout Angular Cryptography is released under the Apache License.