Skip to main content

A Python package for performing Bit Stuffing and Byte Stuffing operations

Project description

Python library to perform Bit Stuffing and Byte Stuffing

To install

pip install pyStuffing

1. Bit Stuffing usage example.

from pyStuffing import BitStuffing
from pyStuffing import clear

if __name__ == "__main__":
    stuff = BitStuffing()
    stuff.startStuffing() # START STUFFING
    stuff.startUnstuffing()

    clear() # CLEAR SCREEN

    # PRINT SEQUENCES TO SCREEN
    print("Main Sequence:       {}".format(stuff.sequence))
    print("Stuffed Sequence:    {}".format(stuff.stuffed))
    print("Un-Stuffed Sequence: {}".format(stuff.unStuffed))
    print("Stuffed Sequence:    {}".format(stuff.getStuffedColored()))

Explanation

  1. Inititallise the class BitStuffing() You can pass the bit sequence to the class as a list.
  • BitStuffing([0,0,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0])
  • If nothing is passed on to the class, you will be prompted for input.
  1. Start the bit stuffing by calling the .startStuffing() method.
  2. The input sequence is obtained as .sequence object.
  3. The bit stuffed sequence is available as the .stuffed object.
  4. The un-stuffed sequence can be obtained as the .unStuffed object.
  5. The .getStuffedColored() returns the stuffed sequence along with the added flags, when printed, explicitly differentiates between the colors of the main sequence, bits stuffed and the flag. Example Colored Output

2. Byte Stuffing usage example.

from pyStuffing import ByteStuffing
from pyStuffing import clear


if __name__ == "__main__":
    stuff = ByteStuffing(list("abcdefghijklmnopqrstuvwxyz".upper()), escape_character="E", flag_character="F")
    # stuff = ByteStuffing()
    stuff.startStuffing()
    stuff.startUnStuffing()

    clear()

    print("Sequence:  {}".format(stuff.sequence))
    print("Stuffed:   {}".format(stuff.stuffed))
    print("Un-stuffed: {}".format(stuff.unStuffed))

Explanation

  1. Initiallise the class ByteStuffing() You can pass the byte sequence to the class as a list.
  • ByteStuffing(list("abcdefghijklmnopqrstuvwxyz".upper()))
  • If nothing is passed on to the class, you will be prompted for input.
  1. Start the bit stuffing by calling the .startStuffing() method.
  2. The input sequence is obtained as .sequence object.
  3. The bytes stuffed sequence is available as the .stuffed object.
  4. The un-stuffed sequence can be obtained as the .unStuffed object.

Note:

You can set the .stuffed object to the stuffed sequence and call the .startUnstuffing() to unstuff the sequence and be obtained sa the .unStuffed object.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyStuffing-0.0.4.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

pyStuffing-0.0.4-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page