Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Simple Cross platform 256bit AES encryption / decryption for NativeScript. Encryption/decryption messages between NativeScript & NodeJS.

License

Notifications You must be signed in to change notification settings

jibon57/nativescript-crossplatform-aes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This plugin is deprecated. Feel free to use the nativescript-simple-libsodium

npm npm Build Status

nativescript-crossplatform-aes

Simple Cross platform 256bit AES encryption / decryption based on Cross-Platform-AES

Note: I am not an expert of neigher iOS nor Android. So, please contribute if you think something you can do better :)

Platforms supported

  1. iOS
  2. Android
  3. NodeJS

Features:

  1. Cross platform support. Encryption-Decryption works across iOS, Android and Node.js.

  2. Automatically RandomIV is added while encryption and remove first randomized blocks while decryption.

  3. Support for Random IV (initialization vector) for encryption and decryption. Randomization is crucial for encryption schemes to achieve semantic security, a property whereby repeated usage of the scheme under the same key does not allow an attacker to infer relationships between segments of the encrypted message.

  4. Support for SHA-256 for hashing the key. Never use plain text as encryption key. Always hash the plain text key and then use for encryption. AES permits the use of 256-bit keys. Breaking a symmetric 256-bit key by brute force requires 2^128 times more computational power than a 128-bit key. A device that could check a billion billion (10^18) AES keys per second would in theory require about 3×10^51 years to exhaust the 256-bit key space.

Installation

tns plugin add nativescript-crossplatform-aes

Simple Usage in NativeScript

import { CrossPlatformAES } from 'nativescript-crossplatform-aes';

let cryptLib = new CrossPlatformAES();
let plainText = "this is my plain text"
let key = "your key"

let cipherText = cryptLib.encryptPlainTextWithRandomIV(plainText, key);
console.log(cipherText);

let decryptedString = cryptLib.decryptCipherTextWithRandomIV(cipherText, key)
console.log(decryptedString);

Other Custom Methods

encryptPlainTextWithSuppliedIV(plainText: string, key: string, iv: string);
decryptCipherTextWithSuppliedIV(cipherText: string, key: string, iv: string);
generateRandomIV16();

NodeJS

Install the library

npm install @skavinvarnan/cryptlib --save

Then use it

const cryptLib = require('@skavinvarnan/cryptlib');

const plainText = "this is my plain text";
const key = "your key";

const cipherText = cryptLib.encryptPlainTextWithRandomIV(plainText, key);
console.log('cipherText %s', cipherText);

const decryptedString = cryptLib.decryptCipherTextWithRandomIV(cipherText, key);
console.log('decryptedString %s', decryptedString);

About

Simple Cross platform 256bit AES encryption / decryption for NativeScript. Encryption/decryption messages between NativeScript & NodeJS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published