Skip to content
/ IDEA Public

The IDEA cypher implementation in JavaScript

License

Notifications You must be signed in to change notification settings

aleen42/IDEA

Repository files navigation

IDEA

npm javascript

It is about the International Data Encryption Algorithm, a.k.a IDEA cypher which is implemented in JavaScript within ~10 KiB. If you want better compatibility, you may need the polyfill version dist/idea.all.js, which has shimmed Int8Array for you.

Compatibility

  • IE6+ (polyfills required for ES7- browsers)
  • NodeJS

Install

npm install @aleen42/idea

Usage

  • without padding:

    function paddingToBytes(str) {
        typeof str !== 'string' && (str = JSON.stringify(str));
    
        const blockSize = 8;
        const srcBytes = encoder.encode(str);
        const len = Math.ceil(srcBytes.length / blockSize) * blockSize; // padding with \x00
        const src = new Int8Array(len);
        src.set(srcBytes);
        return src;
    }
    
    const IDEA = require('@coremail/idea');
    const idea = new IDEA(str2bytes('private key'), /* no padding */-1);
    idea.encrypt(paddingToBytes('message')); // => Int8Array[]
  • with xor padding (ENC3 by default):

    const encoder = new TextEncoder(); 
    const IDEA = require('@coremail/idea');
    const idea = new IDEA(str2bytes('private key'), /* ENC3 by default */197);
    idea.encrypt(encoder.encode('message')); // => Int8Array[]

Release History

  • ==================== 1.0.0 Initial release ====================

⛽ How to contribute

Have an idea? Found a bug? See how to contribute.

📜 License

MIT © aleen42

About

The IDEA cypher implementation in JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published