/simpleSubstitution

Implementation of the simple substitution encryption method, built with Eclipse.

Primary LanguageJava

simpleSubstitution

Implementation of the simple substitution encryption method.

Introduction

Simple substitution is a form of classical cryptography in which monoalphabetic substitutions are executed to provide encryption / decryption. In order to perform these substitutions, a 'cipher alphabet' needs to be created. This alphabet is generated by taking a user key input, removing all repeating characters, and appending remaining alphabetic characters to the end. This implementation appends remaining characters in reverse ASCII order.

For example, if the user key input was "CIPHER EXAMPLE"...

  1. Repeating characters removed from key --> CIPHERXAML
  2. Append remaining alphabetic characters (in reverse ASCII order) to end --> CIPHERXAMLZYWVUTSQONKJGFDB

This cipher alphabet is then used to encrypt text. For example, if the user input was "ENCRYPTION", the encrypted output would be "EVPQDTNMUV". To visualize this, consider the two alphabets aligned:

C I P H E R X A M L Z Y W V U T S Q O N K J G F D B

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

How to use

  • To create the 'cipher alphabet', call: SimpleSubstitution obj = new SimpleSubstitution(String phrase);
  • To encrypt / decrypt based on this 'cipher alphabet', call: obj.translate(String inpt, boolean type);
    • NOTE: false indicates encryption, true decryption

Implementation

This project has been optimized to scale with user input. This is accomplished via QuickSort, which provides a predictable order of characters upon interaction.

Mobile interface

The Google Play application Cipher - Simple Substitution employs this functionality.