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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rubik-cipher

v0.1.9

Published

Simple rubik cube cipher

Readme

Rubik cipher

pipeline status coverage report npm version

Basic implementation of rubik cipher.

Installation

npm install rubik-cipher --save

Usage

RubikCipherConfig

Configuration object that is passed when creating new RubikCipher | field | type | default | required | explanation | |:--------------:|:-------:|:-------:|:--------:|:-----------------------------------------------------------------:| | cubeSize | number | 2 | no | How large is the cube (n*n)) | | groupSize | number | 1 | no | By how many chars group the divided string | | fillRest | boolean | true | no | If the rest of cube spaces will be filled or left empty | | fillWithRandom | boolean | false | no | If the spaces will be filled by char 'x' or with random character |

JavaScript

Creation

const RubikCipher = require('rubik-cipher');

// Creates cube with default parameters
const defaultCube = new RubikCipher('hello world!');

// Creates cube with RubikCipherConfig
const configCube = new RubikCipher('hello world!', {
  cubeSize: 2,
  groupSize: 1,
  fillRest: true,
  fillWithRandom: true,
});

// Creates and decodes cube with selected key config
// keyCube.Text should be 'testxxxxxxxxxxxxxxxxxxxx'
const keyCube = new RubikCipher('xsxtxtxxxxxexxxxxxxxxxxx', '2+1+1+0+B111 L012 B113 D111 B013');
Values

// By using default parameters the fillRest is true, so the rest of the string after typed text is char 'x' 
// example: 'hello world!xxxxxxxxxxxx'
const currentText = cube.Text; 

// Generated combination that follows pattern: 'B111 L012 B113 D111 B013'
// B113 -> move+isWide+depth+rotation -> move = B, isWide = 1 (true), depth = 1, rotation = 3 (3 equals to -1)
const currentRandomCombination = cube.Combination;

// Gets the current key that is in format: 'cubeSize+groupSize+fillRest+fillWithRandom+Combination'
// example: '2+1+1+0+B111 L012 B113 D111 B013'
// where cubeSize is 2, groupSize is 1, fillRest is true, fillWithRandom is false and Combination is 'B111 L012 B113 D111 B013'
const currentKey = cube.Key;
Modifications

// Scrambles the cube cubeSize^3 times
cube.scramble();

// Scrambles the cube 20 times.
cube.scramble(20);

// Adds cubeSize^3 more generated moves to the combination.
cube.addScramble();

// Adds 20 more generated moves to the combination.
cube.addScramble(20);

// Manual string sequence turn
cube.turn('L112 U112 B013 D111');

// Manual object array sequence turn
cube.turn([{ depth: 1, wide: false, target: 'U', rotation: 1 }]);

// Clears the cube of scrambles
cube.reset();
Examples

const RubikCipher = require('rubik-cipher');
const cube = new RubikCipher('HelloWorld!', {
  groupSize: 1,
  fillRest: true,
  fillWithRandom: false,
});
cube.scramble();

const ciphreKey = cube.Key;
const ciphreText = cube.Text;

const result = new RubikCipher(ciphreText, ciphreKey);
const decodedText = result.Text;

TypeScript

import RubikCube from 'rubik-cipher';
const cube = new RubikCipher('HelloWorld!', {
  groupSize: 1,
  fillRest: true,
  fillWithRandom: false,
});
cube.scramble();

const ciphreKey = cube.Key;
const ciphreText = cube.Text;

const result = new RubikCipher(ciphreText, ciphreKey);
const decodedText = result.Text;

Test

npm run test