Ionic Framework 4 is almost here. Preview the beta docs and try it out now! Try Ionic 4 Beta

AES256

Improve this doc

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.

Repo: https://github.com/Ideas2IT/cordova-aes256

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-aes256-encryption
    $ npm install --save @ionic-native/aes-256
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { AES256 } from '@ionic-native/aes-256';


constructor(private aES256: AES256) { }

...


this.aES256.encrypt('12345678123456781234567812345678', '1234567812345678', 'testdata')
  .then(res => console.log('Encrypted Data: ',res))
  .catch((error: any) => console.error(error));

this.aES256.decrypt('12345678123456781234567812345678', '1234567812345678', 'encryptedData')
  .then(res => console.log('Decrypted Data : ',res))
  .catch((error: any) => console.error(error));

Instance Members

encrypt(secureKey, secureIV, data)

This function used to perform the aes256 encryption

Param Type Details
secureKey string

A 32 bytes string, which will used as input key for AES256 encryption.

secureIV string

A 16 bytes string, which will used as initial vector for AES256 encryption.

data string

A string which will be encrypted

Returns: Promise<string> Returns a promise that resolves when encryption happens. The success response will returns encrypted data.

decrypt(secureKey, secureIV, data)

This function used to perform the aes256 decryption

Param Type Details
secureKey string

A 32 bytes string, which will used as input key for AES256 decryption.

secureIV string

A 16 bytes string, which will used as initial vector for AES256 decryption.

data string

An AES256 encrypted data which will be decrypted.

Returns: Promise<string> Returns a promise that resolves when decryption happens. The success response will returns decrypted data.

API

Native

General