Giter VIP home page Giter VIP logo

caesarcipher's Introduction

CaesarCipher

A basic implementation of the Caesar Cipher encryption using Java.

Caesar Cipher is a simple encryption algorithm. Given a string of letters and a number key (say 'k'), it shifts all the letters of the string by 'k' positions according to the alphabet. If we start with A = 0 we would then have Z = 25. If we consider the letter 'D' and the key as 3 (k = 3), then the letter will be now represented as 'G' which is three places next to D in the alphabet. After Z, we come back to A i.e., it is a cyclic consideration.

(Using the edu.duke library and originally executed in BlueJ environment -- credits to Duke University and Coursera)

Methods used in this project:

CAESAR CIPHER (to perform the encryption):

  1. String encrypt(String input, int key) -- the "input" string is encrypted with 'key'. We are encrypting the whole message using only one key.
  2. void test() -- to test encrypt()
  3. String encryptTwoKeys(String input, int key1, int key2) -- in the "input" string, all the odd positions are encrypted with 'key1', even positions are encrypted with 'key2'
  4. void testEcryptTwoKeys() -- to test encryptTwoKeys()

CAESAR BREAKER (Decrypting Caesar Cipher encryption):

  1. countLetters() - counts the number of occurences of each letter and stores it in an array
  2. maxIndex() - finds out the most-occured letter
  3. decrypt() - decrypts the encrypted message (only one key)
  4. halfOfString() - returns a new String that is every other character from message starting with the start position
  5. getKey() - calls countLetters() and maxIndex() and returns the max freq letter

CAESAR CIPHER II (For the Object-oriented implementation):

  1. Construction performs shifting of alphabet using 2-key encryption
  2. String encrypt(String input) -- the "input" string is encrypted (2 keys)
  3. String decrypt(String input) -- the "input" string is decrypted (2 keys)
  4. void simpletests() -- to test the encryption and decryption methods

caesarcipher's People

Contributors

rhemamarneni 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.