Skip to content

Allows you to encrypt/decrypt using AES from CryptoJS. Provides a service which you can inject anywhere in your system. You have to configure the service to setup the KEY before you use it

License

Notifications You must be signed in to change notification settings

arkan/angular-cryptography

Repository files navigation

AngularJS Module that integrate cryptography functionality offers from the crypto-js project. Provides a simple service to encrypt and decrypt using AES.

Dependencies

##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)

  • download js file
  • download js file
  • added javascript file to your app html file
<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 !

Issues

License

Middleout Angular Cryptography is released under the Apache License.

About

Allows you to encrypt/decrypt using AES from CryptoJS. Provides a service which you can inject anywhere in your system. You have to configure the service to setup the KEY before you use it

Resources

License

Stars

Watchers

Forks

Packages

No packages published