Giter Club home page Giter Club logo

shift_decoder's Introduction

shift_decoder

'shift_decoder' is used to decode texts that have been encoded using a Caesarian shift, without having any knowledge of its key. The ciphertext can either be manually inputted, or sourced in a file. It uses letter frequency analysis to determine the most likely shift key. Because of this, larger sections of text with a more representative frequency will be more likely to work with the first recommended key. However, There is also an interactive console that allows users to shift by any key they wish, and to change the ciphertext to a different string

Functions

  • eval_ciphertext( ciphertext ):
    This is the primary function for the general evaluation of a ciphertext. This includes:

    • finding the frequency of each letter in the ciphertext
    • finding recommended shift keys
    • printing the ciphertext after shifting it with the most recommended key
    • printing other recommendations if the best key was wrong param ciphertext: the encoded string
  • freq( ciphertext ):
    Iterates through a ciphertext and totals the occurrences of each letter param ciphertext: the encoded string return: a dictionary mapping English letters to their frequency in the given text

  • get_shift_keys( ciphertext, text_freq ):
    For each letter in the ciphertext, its 'closest letter' is found. The difference between the closest letter and the original represents a shift key. Occurrences of shift keys are totaled, at the top 3 are returned. param ciphertext: the encoded string param text_freq: a dictionary mapping the frequency of each letter in the text return: a 3-tuple of ints containing the top 3 options for shift keys

  • shift( ciphertext, shift_key ):
    Performs a Caesarian shift on a text param ciphertext: the encoded string param shift_key: the amount you want to shift by return: a string representing the ciphertext after it has been shifted

  • closest_letter( freq_percentage ):
    Finds the 'closest letter' by comparing the percentage of use in a given text to the standard English frequency percentages param freq_percentage: frequency percentage of a certain letter in a ciphertext return: the letter that the percentage most closely corresponds to

  • empty_freq_dict():
    return: a dictionary mapping English letters to their frequency in a text, initialized to 0

  • english_letter_frequency():
    Figures taken from the Wikipedia article on Letter Frequency return: dictionary mapping English letters to their frequency, given in percentages

shift_decoder's People

Contributors

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