Skip to content

fazalfarhan01/pyStuffing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Python package for performing Bit Stuffing and Byte Stuffing operations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages