Coder Social home page Coder Social logo

aishdec's Introduction

Aishdec

Aishdec is a NodeJS console script that'll try to decrypt a Vigenere ciphred text using Kasiski's method.

How does this works?

This works with the Kasiski's method principles:

  • There're common text paths in the text with a length of 2-3-4... (Relative)
  • The distance between these common paths is a multiple of the key length

To put this in practice, we search in the text for common trigrams, and then we calculate the distance between these. Then, with these distances, we get the greates common divisor, that'll be the length of the key we're looking for. After that, we find out N substrings derived from the original text, with N equals to the key length. Example: ABCDEF with key length equals 3. We'll get 3 substrings:

  • AD (A, A + 3...)
  • BE (B, B + 3...)
  • CF (C, C + 3...)

With the substrings found, now you're gonna look for the most frequent letters on each substring. In our script, we're using for the most common letter in English alphabet, that's the E letter (We also used A, but we didn't found the expected resultes). Then, with the common letter found on EACH substring, we know that E has a distance of 4 letters with the A, so we'll look for the relative A letter to our relative E found. Example: If we found these frequent letters: [G, K, L] the relative As should be: [E, G, H]

And finally, these As letter should be the key that' we're looking for, and we can decrypt the message with simple specials math.

Getting Started

Prerequisites

You're gonna need Node
Then you're gonna need to install the project dependencies

npm install 

Trying out

You can run the next command to try the automatic decryption in the package's dir

node aishdec

You can also personalize a bit the script execution, defining some stuff like the size of substrings to search in the text, or the length of the key (In case you know it)

node aishdec --group-by=NUMBER (Default one is 3)
node aishdec --key-length=NUMBER
node aishdec --key=TEXT (This will just decrypt the whole message without JSON details)

Also, you can import aishdec and use it in your code as a simple function

aishdec's People

Contributors

santb08 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.