Giter VIP home page Giter VIP logo

theory_of_crypto_lab's Introduction

LZ77 Compression and Shannon Entropy Calculator

This repository contains Python implementations of the LZ77 compression algorithm and a Shannon entropy calculator. These tools are designed to help understand and analyze the efficiency of text compression and the inherent information content in data.

Features

  • LZ77 Compression: Encode text using the LZ77 algorithm, which is useful for understanding basic concepts in data compression techniques.
  • Shannon Entropy Calculator: Compute the Shannon entropy for a given text to understand the theoretical limits of lossless compression for that text.

Getting Started

To use these scripts, you will need Python installed on your computer. These scripts are tested with Python 3.8 but should be compatible with other Python 3.x versions.

Prerequisites

Ensure you have Python installed. You can download Python from python.org.

Installation

Clone this repository to your local machine using:

gh repo clone Floressek/Theory_of_crypto_lab
cd your-repository-directory

Usage

LZ77 Compression

To encode text using the LZ77 algorithm, run the Encoded.py script. You will be prompted to enter the dictionary size, buffer size, and the text you want to compress.

python Encoded.py

Follow the prompts to input your parameters and text.

Shannon Entropy Calculator

To calculate the Shannon entropy of a given text, run the Shannon_result_table.py script. You will need to input the text for which you want the entropy calculated.

python Shannon_result_table.py

Examples

Here's how you can use the LZ77 encoding script:

Enter the dictionary size: 15
Enter the buffer size: 5
Enter the text to encode: BAADAADDDBEEDAAEAADAABDDA

Output:

Dictionary           | Buffer               | Remaining            | Match               
------------------------------------------------------------------------------------
                     | BAADA                | ADDDBEEDAAEAADAABDDA | <0, 0, B>
B                    | AADAA                | DDDBEEDAAEAADAABDDA  | <0, 0, A>
BA                   | ADAAD                | DDBEEDAAEAADAABDDA   | <1, 1, D>
BAAD                 | AADDD                | BEEDAAEAADAABDDA     | <3, 3, D>
BAADAADD             | DBEED                | AAEAADAABDDA         | <5, 1, B>
BAADAADDDB           | EEDAA                | EAADAABDDA           | <0, 0, E>
BAADAADDDBE          | EDAAE                | AADAABDDA            | <1, 1, D>
BAADAADDDBEED        | AAEAA                | DAABDDA              | <12, 2, E>
AADAADDDBEEDAAE      | AADAA                | BDDA                 | <15, 5, B>
DDBEEDAAEAADAAB      | DDA                  |                      | <15, 2, A>
Encoded LZ77: [(0, 0, 'B'), (0, 0, 'A'), (1, 1, 'D'), (3, 3, 'D'), (5, 1, 'B'), (0, 0, 'E'), (1, 1, 'D'), (12, 2, 'E'), (15, 5, 'B'), (15, 2, 'A')]
Amount of encoded words: 10

Contributing

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

theory_of_crypto_lab's People

Contributors

floressek avatar

Stargazers

 avatar

Watchers

 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.