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

@mezgoodle/caesar-and-vigenere-ciphers

v2.1.0

Published

NPM package of caesar-and-vigenere-ciphers

Downloads

6

Readme

Caesar and Vigenere ciphers

Hello everyone! This is the repository of my package on JavaScript "Caesar and Vigenere ciphers"

Table of contents

Motivation

I've always been interested in the topic of data encryption, but I didn't delve deeply into it. So I decided to do it on. At first there was an idea to do a CLI or an Electron application. But later it turned into a package for npm.

Build status

Here you can see build status of continuous integration/continuous deployment:

Node.js Package Build Status pipeline status Build Status npm node-current

Code style

I'm using Codacy for automate my code quality.

Codacy Badge

Dependencies

David

I'm using only jest for testing, but that's enough for unit-testing. You may not install it.

You can see all dependencies from package-lock.json here.

Features

With my package you can encrypt / decrypt text with Caesar and Wiegener algorithms with latin, cyrillic or greek alphabet based on UTF-16.

If you see incorrect work with alphabet, please write an issue.

Installation

First install Node.js. Then:

npm i @mezgoodle/caesar-and-vigenere-ciphers --save

Importing

// Using Node.js `require()`
const { caesarEncrypt, caesarDecrypt, vigenereEncryptText, vigenereDecryptText } = require("@mezgoodle/caesar-and-vigenere-ciphers");

Fast usage

// Latin

console.log(caesarEncrypt("pellentesque", 12, "lat"));
// expected output: bqxxqzfqecgq
console.log(caesarDecrypt("pellentesque", -12, "lat"));
// expected output: bqxxqzfqecgq
console.log(vigenereEncrypt("unopinionated", "express", "lat"));
// expected output: ykdgmfaskpkiv
console.log(vigenereDecrypt("ykdgmfaskpkiv", "express", "lat"));
// expected output: unopinionated

// Cyrillic

console.log(caesarEncrypt("привет", 2, "cyr"));
// expected output: сткдзф
console.log(caesarDecrypt("сткдзф", 2, "cyr"));
// expected output: привет
console.log(vigenereEncrypt("Карл у Клары украл кораллы", "кларнет", "cyr"));
// expected output: Флры а Пэкыы гчхтх хоанрэе
console.log(vigenereDecrypt("Флры а Пэкыы гчхтх хоанрэе", "кларнет", "cyr"));
// expected output: Карл у Клары украл кораллы

// Greek

console.log(caesarEncrypt("αβ", 1, "gre"));
// expected output: βγ
console.log(caesarDecrypt("βγ", 1, "gre"));
// expected output: αβ
console.log(vigenereEncrypt("ΓειΑ", "βι", "gre"));
// expected output: ΔνκΙ
console.log(vigenereDecrypt("ΔνκΙ", "βι", "gre"));
// expected output: ΓειΑ

API

caesarEncrypt( value, amount, type )

Name | Type | Argument | Default | Description --------|----------|--------------|---------|------------ value | string | <required> | null | the message to encrypt amount | number | <required> | null | the key to encrypt the message with type | string | <required> | null | the type of language: latin or cyrillic

caesarDecrypt( value, amount, type )

Name | Type | Argument | Default | Description --------|----------|--------------|---------|------------ value | string | <required> | null | the message to decrypt amount | number | <required> | null | the key to decrypt the message with type | string | <required> | null | the type of language: latin or cyrillic

vigenereEncrypt( text, key, type )

Name | Type | Argument | Default | Description --------|----------|--------------|---------|------------ text | string | <required> | null | the message to encrypt key | string | <required> | null | the key to encrypt the message with type | string | <required> | null | the type of language: latin or cyrillic

vigenereDecrypt( text, key, type )

Name | Type | Argument | Default | Description --------|----------|--------------|---------|------------ text | string | <required> | null | the message to decrypt key | string | <required> | null | the key to decrypt the message with type | string | <required> | null | the type of language: latin or cyrillic

Code Example

Here you can see small example of Vigenere worker

const worker = (str, key, type, lang) => {
  if (typeof(key) !== 'string' || typeof(str) !== 'string')
    throw Error('Text and Key must be string');
  if (!Object.prototype.hasOwnProperty.call(typeDefine, lang))
    throw Error('Type must be "lat" or "cyr"');
  if (str === null || key === null) throw Error('Message and key should be not empty');
  key = keepLetters(key);
  let result = '',
    keyIndex = 0;
  for (let i = 0; i < str.length; i++) {
    const char = str.charAt(i);
    if (isLetter(char)) {
      const key_el = key.charAt(keyIndex++ % key.length);
      const temp = workerChar(char, key_el, type, lang);
      result += temp;
    } else {
      result += char;
    }
  }
  return result;
};

Tests

Unit-testing with assert and jest:

Early here were screenshots

Number of my tests is more than 50, so I can't just do screenshot :smile:. I give you the link to Travis CI, where you can see all my tests.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GitHub

MIT © mezgoodle