Git Product home page Git Product logo

caesarcipher's Introduction

Maven Central

Caesar Cipher (Keyed Caesar) java library

Java library for Ceasar Cipher (Keyed Caesar) that can:

  1. Encrypt & decrypt english text using keyword and keyword offset (shift)
  2. Hack encrypted english text using frequency of letters and dictionary of words

Requirements

  • Java JDK 1.8 or later

Installation

Maven users

<dependency>
  <groupId>com.github.maximan3000</groupId>
  <artifactId>caesar-cipher</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle Groovy DSL

implementation 'com.github.maximan3000:caesar-cipher:1.0.0'

Algorithm

Usage

Encrypt/Decrypt text

Create an encryption system instance

import com.grayen.encryption.caesar.algorithm.Caesar;
import com.grayen.encryption.caesar.algorithm.implementation.CaesarFabric;

Caesar encryption = CaesarFabric.getEncryptionSystem();

Encrypt text using your keywords and offset or it's default values

String textToEncrypt = "Text need to encrypt";

String encryptedText = encryption.encrypt(textToEncrypt, "keyword", 5);

Decrypt with the same way

String textToDecrypt = "Xcyx pccb xq cpauwsx";

String decryptedText = encryption.decrypt(textToDecrypt, "keyword", 5);

Hack text

Hack system uses dictioanry with english words to improve hacking quality. So you need to create string array with many words. To do that, download large book with .txt extention and parse it to string[].

import java.nio.file.FileSystems;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Files;

Path sourceFile = FileSystems.getDefault().getPath("BigBook.txt");
List<String> fileLines = Files.readAllLines(sourceFile, StandardCharsets.UTF_8);
String[] dictionary = fileLines.toArray(new String[0]);

Create hack system instance.

  • Note 1: successful hack depends on encrypted text size
  • Note 2: text for dictionary should be large
import com.grayen.encryption.caesar.hack.Hack;
import com.grayen.encryption.caesar.hack.implementation.HackFactory;

Hack hack = HackFactory.getCaesarEncryptionHack(encryptedText, dictionary);

Hack encrypted text

String hackedText = hack.hack();

If it's need, correct hacked text with hands and hack the text again

hack.correctEncryptionTableWithHand("a", "x");
String hackedText = hack.hack();

caesarcipher's People

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.