5.0.0 • Published 3 years ago

natocrypt v5.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NPM

A simple library for hashing passwords or text.

  • Very simple and easy encryption
  • Uses the NATO phonetic alphabet for hashing
  • Encryption using the Morse Code is also available

Explore natocrypt here. \ Learn more about NATO Phonetic Alphabet

This is a zero dependency package.

This package is open to contributions.

🔧Installation:

npm install natocrypt

📜Usage:

const Natocrypt = require("natocrypt");
const nato = new Natocrypt();
const somePassword = "$0m3p4$$w0rD";

🔒Hash a password/text

const encryptedText = nato.encrypt(somePassword);
// encryptedText = { field: 'golfquebecxrayjulietalphajulietechozulufoxtrotsierrawhiskeybravohoteltangosierrasierrabravogolflimaalpha$bravoxraywhiskeyindiaviktornovemberromeoxraycharliexraytangouniformjulietxraygolfwhiskeylimajulietxraywhiskey0deltaalphanovemberbravokiloxrayechoyankeesierrapapadeltadeltalimapapauniformgolfjulietpapaviktoryankeemiketangozulupaparomeoviktorromeoromeoxraydeltaquebecdeltacharliexrayviktorgolfoscarcharliewhiskeykilopapa3novemberalphaalphahotelechosierraalphacharliezuluyankeecharliealphahotelbravoquebecfoxtrotalphayankeecharlieviktorpapaviktorsierraechoyankeezuluquebecfoxtrotviktormikebravoechomikejulietechocharlielimahotelkilooscaroscar4limacharliesierraoscardeltapapaxrayzuluyankeebravooscaruniformalphasierrabravozuludeltasierraoscarfoxtrot$deltasierrapapahotelviktorhoteluniformechoyankeeyankeemikezuluindiatangodeltaquebeckiloxraycharlienovember$tangohoteluniformpaparomeofoxtrotromeosierrabravowhiskeyjulietoscaryankeemikesierradeltaviktorromeolimapapawhiskeymikecharlietangotangoxrayuniformmikelimakiloxrayviktorzulumikepapalimajulietwhiskeyxrayalphaquebec0novemberromeokilonovembermikexraymikeviktoryankeegolflimaindiaviktornovemberbravowhiskeyzuluromeoviktorjulietromeosierrapapaalphanovemberoscarwhiskeyviktorjulietuniformhotellimatangodeltafoxtrothotelgolfechocharlieechodeltaDelta', multiplier: 20 }

🔓Decrypt a text

const decryptedText = nato.decrypt(encryptedText);
// decryptedText = $0m3p4$$w0rD

✔️Check a password

const result  = nato.compare("some other text", encryptedText);
// result = false
Available Characters = " 1234567890-=,./;'`[]<>?:{}!@#$%^&*()_+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

🧂Multipliers

On every encryption, a multiplier will be set be default between 3 and 100. Each multiplier value will make the encryption larger. You could also set a multiplier of your own.

Pass in a multiplier value to the encryption method

const encryptedText = nato.encrypt(somePassword, 50);

🔒Hash a password/text with Morse Code

const encryptedMorse = nato.morse("encrypt", "H3ll0 w0rld!");
// encryptedMorse = "-..- .-. -----.... .-..-. --.. --... ---.. ...- .... -----.- -------.. -.-. .-. --.- -------.- .-..-. .... ...-- -..- ----- -.- --... -..- -----.--. ...- ------.. -----.-.. -----. ------.- -----.... ..--- --.. -....- .-.-.- . -----.-.. -----.--- -----..- -----.-- .--.-. -----.. ------.- ..... ...-..- ----- -.--.- ------.-- . -----.--- --. ....- -----.--- -.--.- ~ --.- --... .--.-. --. -.--. -... .-- -----.-. -----.-- -.-.-. -.--. .-.-. .... ..... ..-. ..--.. ------.-. ----- -.-.-. ------.. ------..- ..... ---... .-- ...-- .-.-.- -----.-. -.-.-. -----.- ..-. - -- - ------..- -.-. -----.-.. -----...- -----.--. -.-. ------..- -------.- -----.--. . .--.-. ------.. -. ------.- .-..-. ------... ------- .--.-. ------.. ...-..- -.-.-- ---.."
Available Characters = " 1234567890.,?'!/()&:;=+-$@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

🔓Decrypt a text with Morse Code

const decryptedMorse = nato.morse("decrypt", encryptedMorse);
// decryptedMorse = H3ll0 w0rld!

🧂Multipliers on Morse Code

On every encryption, a multiplier will be set be default between 1 and 10. Each multiplier value will make the encryption larger. You could also set a multiplier of your own.

Pass in a multiplier value between 1 and 10 to the encrypt option, other values besides these will not work.

const encryptedMorse = nato.morse("encrypt", "H3ll0 w0rld!", 7);

📑API

natocrypt

  • encrypt(field, multiplier)

    • field - REQUIRED - input for the data
    • multiplier - OPTIONAL - hash length (default 3-100)

    return - encrypted object

  • decrypt(field)

    return - decryped string

  • compare(field, hash)

    return - boolean result

  • morse(type, field, multiplier)

    morse(encrypt, field) \ return - encrypted morse text field

    morse(decrypt, field) \ return - decrypted text field

📝Hash Info

Each letter will be a representation of its NATO alphabet. Any other character will be as it is except for spaces. Spaces will be converted to "~", which is excluded from any possible allowed characters. Paragraphs are accepted, however the recommended multiplier value is lower for longer text.

NATO Phonetic Alphabet

AlphaBetaCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliet
ABCDEFGHIJ
KiloLimaMikeNovemberOscarPapaQuebecRomeoSierraTango
KLMNOPQRST
UniformViktorWhiskeyXrayYankeeZulu
UVWXYZ

example

foxtrotechoindiaxraytangoalphapapamikeindiapapasierralimagolfecho
   |     |    |   |    |   |    |   |    |   |    |    |   |   |
  hash   e  hash  x   hash a  hash  m  hash  p  hash   l  hash e
         ^        ^        ^        ^        ^         ^       ^

Morse Code

Since the Morse Code only supports a single case letter system, I added additional code to include capital or lower case letters. Spaces are also added and it will be represented as "~" which is disabled for usage.

.--...-.-.-.....-.--........---
ABCDEFGHIJ
-.-.-..---.---.--.--.-.-....-
KLMNOPQRST
..-...-.---..--.----..
UVWXYZ
-----.-------...------.-.------..-----.-----..-.-------.-----....-----..-----.---
abcdefghij
------.------.-..-------------.-------------.--.-------.------.-.-----...------
klmnopqrst
-----..------...------.--------..-------.---------..
uvwxyz
-----.----..---...--....-.....-....--...---..----.
0123456789
.-.-.---..--..--...----.-.-.---..-.-.--.-.--.-.-...---...
.,?'!/()&:
-.-.-.-...-.-.-.-....-.-..-....-..-.--.-.
;=+-"$@

example

  - -----. --.- ------..- -------.. -----.- .- ------- ... -----.--. -...- -----.-.. .... -----. .----
  |   |     |       |        |         |    |     |     |      |       |       |       |    |      |
  T   e     Q       x        z         a    A     m     S      p       =       l       H    e      1
      ^             ^                  ^          ^            ^               ^            ^

Hash length depends on the multiplier value.

📌Notes:

This package is just the starting of an idea that could grow up into a much secure solution.

Any contributions are greatly welcomed, please provide a detailed explanation of the feature you would like to add, make sure tests are running well before creating a pull request.

If you are submitting a bug or an issue, please provide a sufficient code snippet. Enough information should be provided such that the problem can be replicable. Issues which are closed without resolution often lack required information for replication.

©️License:

Copyright © Kemal Demirgil. All rights reserved. Licensed under the MIT license.

5.0.0

3 years ago

4.0.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago