Git Product home page Git Product logo

ighalogenesisosasenaga / cryptography Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 957 KB

This is a repository exploring different encryption methods.

License: MIT License

C++ 7.78% C 8.14% Java 8.76% CSS 8.16% HTML 3.49% JavaScript 16.45% Kotlin 5.71% Python 41.51%
cipher-algorithms ciphers cryptography encryption-decryption encryption-library enigma enigma-emulator vigenere-cipher python-c-cpp-java-html-javascript-cipher

cryptography's People

Contributors

ighalogenesisosasenaga avatar

Stargazers

 avatar

Watchers

 avatar

cryptography's Issues

Decrypt malfunction in Enigma class

The decrypt function has a problem I can't think of a way to solve.

def _decrypt(self):
        output = ""
        # Variable to store suspected sequences
        current_sequence = ""
        # Replacement dictionary for special characters
        replacement_dict = self._nulls
        # Boolean to know if the current_sequence variable is not empty
        in_sequence = False
        for char in self._lampboard:
            if not in_sequence and char in self._sequence_marker:
                # Start a sequence
                current_sequence += char
                in_sequence = True
            elif in_sequence:
                # Add a character to the current sequence if it's length is less than 3
                current_sequence += char
                if len(current_sequence) == 3:
                    # Current sequence has reached max length, so add the corresponding special character to the output if current_sequence is found in the dictionary else add all the letters in current sequence to the output
                    output += replacement_dict.get(current_sequence, current_sequence)
                    # Important reset
                    current_sequence = ""
                    in_sequence = False
            else:
                # Add character to output as character doesn't begin a null sequence and current_sequence is empty 
                output += char
        return output

This function actually gets called after decryption though. It's purpose is to replace special sequences in decrypted text with a special character mapped to the sequence.
E.g

input: HELLOHRLWORLD
return value: HELLO WORLD

Problem

  1. Test 1
input: JUSTHRLME
return value: JUSTHRLME
  1. Test 2
input: THISHRLFOOD
return value: THI)LFOOD

At first I thought the sequence of nulls for special characters would be good. But that didn't seem to work out in my head. So I'd really appreciate help on this.

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.