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

node-ice

v1.1.1

Published

NodeJS Information Concealment Engine (ICE) algorithm

Downloads

17

Readme

node-ice

Information Concealment Engine (ICE) encryption/decryption algorithm in TypeScript.

import {IceKey} from 'node-ice';

const iceKey = new IceKey(1);
iceKey.set(new Uint8Array([0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89]));

const toEncrypt = new Uint8Array([0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]);
const encrypted = new Uint8Array(8);
const decrypted = new Uint8Array(8);

iceKey.encrypt(toEncrypt, encrypted);
iceKey.decrypt(encrypted, decrypted);

console.log(`To encrypt: ${toEncrypt}`);
console.log(`Encrypted: ${encrypted}`);
console.log(`Decrypted: ${decrypted}`);

Install

npm i node-ice -S

Algorithm

More info about the algorithm: http://www.darkside.com.au/ice/

Docs

An IceKey object is used to encrypt and decrypt 8-byte blocks of data using the ICE encryption algorithm. ICE, an acronym for Information Concealment Engine, is a 64-bit block cipher in the tradition of DES. However, it aims to be faster and significantly more secure than DES.

Unlike DES, ICE has various levels of encryption, where higher levels provide more security, but at the expense of speed. It also makes use of a technique called keyed permutation internally, which gives it increased resistance to differential and linear cryptanalysis.

Once an IceKey object has been created, it will usually have its key set from a password of some sort. The object can then be used to encrypt and decrypt data using that key.

Constructors

IceKey

public IceKey(int level)
  • Creates an IceKey object. The level parameter specifies the level of ICE encryption to use, where higher levels require longer keys and are slower, but are more secure. Level 0 uses the Thin-ICE variant of ICE, which is an 8-round cipher taking an 8-byte key. This is the fastest option, and is generally considered to be at least as secure as DES. For levels n greater than zero, a 16n-round cipher is used, taking 8n-byte keys. Although not as fast as level 0, these are very secure.

  • Parameters:

    • level - the ICE level of encryption

Methods

set

public void set(key: Uint8Array)

This method sets the key schedule for the IceKey. This should be called before any encryption or decryption is done, or the results will not be secure. The number of key bytes used depends on the level of encryption set in the constructor. For levels 0 and 1, 8 bytes are used. For levels n > 1, 8n bytes are used. If the key array is not large enough to contain the required number of bytes, an array bounds error will occur.

  • Parameters:
    • key - the key used to encrypt and decrypt data

encrypt

public void encrypt(plaintext: Uint8Array, ciphertext: Uint8Array)

This method is called to encrypt 8 bytes of the plaintext with the key specified in the set method. The result is stored in the ciphertext array.

  • Parameters:
    • plaintext - the data to be encrypted
    • ciphertext - the resulting encrypted data

decrypt

public void decrypt(ciphertext: Uint8Array, plaintext: Uint8Array)

This method is called to decrypt 8 bytes of the plaintext with the key specified in the set method. The result is stored in the plaintext array.

  • Parameters:
    • ciphertext - the data to be decrypted
    • plaintext - the resulting decrypted data
public void decryptUint8Array(cipherArray: Uint8Array, plainArray: Uint8Array, 
			      from?: number, to?: number)

This method is called to decrypt an entire Uint8Array of the plaintext with the key specified in the set method. The result is stored in the plaintext array.

  • Parameters:
    • cipherArray - the data array to be decrypted
    • plainArray - the resulting decrypted data array
    • from (optional) - decrypt cipherArray starting with from index
    • to (optional) - decrypt cipherArray until to index

The decrypted data is always stored in plainArray starting with index 0.

clear

public void clear()

This method zeroes out the key schedule, which prevents memory snoopers from finding key information. It should only be called when the key is no longer needed for encryption or decryption.

keySize

public int keySize()

This method returns the key size, in bytes.

blockSize

public int blockSize()

This method returns the block size, in bytes. The value is always 8.