JSPM

react-native-aes-ecb

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 47
    • Score
      100M100P100Q59858F
    • License MIT

    A pure JavaScript implementation of the AES block cipher algorithm with additional features for react-native.

    Package Exports

    • react-native-aes-ecb
    • react-native-aes-ecb/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-aes-ecb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    REACT-NATIVE-AES-ECB

    A pure JavaScript implementation of the AES block cipher algorithm and features.

    Simple and very secure Cipher for encrypt and decrypt some sensetive string values.

    Features

    • Pure JavaScript
    • key size (must be 128 bits (16 bytes), 192 bits (24 bytes) or 256 bits (32 bytes))
    • Supports all key sizes (128-bit, 192-bit and 256-bit)
    • Supports all common modes of operation ( ECB )
    • Added prefix feature

    Strings and Bytes

    Strings could be used as keys. But UTF-8 allows variable length, multi-byte characters, so a string that is 16 characters long may not be 16 bytes long.

    Also, UTF8 should NOT be used to store arbitrary binary data as it is a string encoding format, not a binary encoding format.

    API

    React native

    To install react-native-aes-ecb in your react native project:

    npm install react-native-aes-ecb

    And to access it from within you app, simply add:

    var aesEcb = require('react-native-aes-ecb');

    KeyString must be 128 bits (16 bytes), 192 bits (24 bytes) or 256 bits (32 bytes) long.

    How it works

    keyString - is some unique secret key that takes part in encryption and decryption process.

    input - is any string that you want to be encrypted and decrypted later.

    var keyString = 'KeyMustBe16ByteOR24ByteOR32Byte!';
    var input = 'Some secret string that should be encrypted or decrypted !';
    
    var encrypt = aesEcb.encrypt(keyString, input);
    var decrypt = aesEcb.decrypt(keyString, input);

    Example with "Hello world!"

    //Encrypt
    
    aesEcb.encrypt('KeyMustBe16ByteOR24ByteOR32Byte!', 'Hello world!')
    
    // result looks like ' C41XiUDI/bEvSwYO1iZvOQ== '
    
    //Decrypt
    
    aesEcb.decrypt('KeyMustBe16ByteOR24ByteOR32Byte!', 'C41XiUDI/bEvSwYO1iZvOQ==')
    
    // result looks like ' Hello world! '
    

    Features

    aes-ecb.encrypt has required arguments as "keyString" and "input",

    and optional as "pref" - prefix & "s" -separator

    Example with "Hello world" and prefix with separator

    IMPORTANT * when you want to use prefix you should use separator also it's required!

    //shema  aesEcb.encrypt(keyString, input, pref, s);
    
    aesEcb.encrypt('KeyMustBe16ByteOR24ByteOR32Byte!', 'Hello world!', "prefix", " :: ");
    
    //result looks like ' prefix::C41XiUDI/bEvSwYO1iZvOQ=='

    IMPORTANT * if you had used prefix and separator for encrypt value so for decrypt you should use separator only, or both prefix and separator as separator!

    //shema  aesEcb.decrypt(keyString, input, s);
    
    aesEcb.decrypt('KeyMustBe16ByteOR24ByteOR32Byte!', 'Hello world!', " :: ");
    
    //result looks like ' Hello world! '
    //shema  aesEcb.decrypt(keyString, input, s);
    
    aesEcb.decrypt('KeyMustBe16ByteOR24ByteOR32Byte!', 'Hello world!', " prefix:: ");
    
    //result looks like ' Hello world! '