npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-aes256-encryption

v2.0.1

Published

This cordova ionic plugin allows you to perform AES 256 encryption and decryption on the plain text. It's a cross-platform plugin which supports both Android and iOS. The encryption and decryption are performed on the device native layer so that the perfo

Downloads

3,873

Readme

Cordova-AES256 Encryption And Decryption

This cordova ionic plugin allows you to perform AES 256 encryption and decryption on the plain text. It's a cross-platform plugin which supports both Android and iOS. The encryption and decryption are performed on the device native layer so that the performance is much faster. The entire operations is performed in the background thread.

AES Encryption Mode

AES 256 CBC mode encryption is used. For Android, PKCS5Padding is used and for iOS PKCS7Padding is used.

Getting Started

  1. Install Plugins
    ionic cordova plugin add cordova-plugin-aes256-encryption

    cordova plugin add cordova-plugin-add-swift-support --save

  2. Declare cordova variable and access the plugin after the platform get initialized

import { Injectable } from '@angular/core';
import { Platform } from 'ionic-angular/index';
declare var cordova: any;

@Injectable()
export class AES256Provider {

  secureKey: String = '12345678910123456789012345678901'; // Any string, the length should be 32
  secureIV: String = '1234567891123456'; // Any string, the length should be 16

  constructor(private platform: Platform) {
      // To generate random secure key
      this.generateSecureKey('some string');  // Optional
      
      // To generate random secure IV
      this.generateSecureIV('some string');   // Optional
      
      let data = "test";
      encrypt(this.secureKey, this.secureIV, data); 
      let encryptedData = "AE#3223==";
      decrypt(this.secureKey, this.secureIV, encryptedData);  
  }

  encrypt(secureKey, secureIV, data) {
    this.platform.ready().then(() => {
      cordova.plugins.AES256.encrypt(secureKey, secureIV, data,
        (encrypedData) => {
          console.log('Encrypted Data----', encrypedData);
        }, (error) => {
          console.log('Error----', error);
        });
    });
  }

  decrypt(secureKey, secureIV, encryptedData) {
    this.platform.ready().then(() => {
      cordova.plugins.AES256.decrypt(secureKey, secureIV, encryptedData,
        (decryptedData) => {
          console.log('Decrypted Data----', decryptedData);
        }, (error) => {
          console.log('Error----', error);
        });
    });
  }
  
  generateSecureKey(password) {
    this.platform.ready().then(() => {
      cordova.plugins.AES256.generateSecureKey(password,
        (secureKey) => {
          this.secureKey = secureKey;
          console.log('Secure Key----', secureKey);          
        }, (error) => {
          console.log('Error----', error);
        });
    });
  }
  
  generateSecureIV(password) {
    this.platform.ready().then(() => {
      cordova.plugins.AES256.generateSecureIV(password,
        (secureIV) => {
          this.secureIV = secureIV;
          console.log('Secure IV----', secureIV);          
        }, (error) => {
          console.log('Error----', error);
        });
    });
  }

}

Installation Errors

Failed to install 'cordova-plugin-aes256-encryption': CordovaError: Version of installed plugin: "[email protected]" does not satisfy dependency plugin requirement "cordova-plugin-add-swift-support@^2.0.1". Try --force to use installed plugin as dependency.

If Above error has occurred then run

ionic cordova plugin add cordova-plugin-aes256-encryption --force --save

References

https://developer.android.com/reference/javax/crypto/Cipher

https://github.com/SwiftyBeaver/AES256CBC