Exemple #1
0
if __name__ == '__main__':
    file_path = "files/files_to_test/test.jpg"

    div = int("1011", 2)
    byte = int("11010011101100", 2)

    div = int("10110001", 2)
    byte = int("1101001110111110010011100", 2)

    crc = get_crc(byte, div)
    crc = get_crc(byte, div, crc)

    file = open(file_path, "rb").read()
    file_list = list(file)

    get_crc_from_file(byte, div)
    get_crc_from_file(byte, div)
    pass

    #
    # byte = int("11010011101100", 2)
    # div = int("1011", 2)
    #
    # print("byte: " + str(bin_len(byte)) + ": " + str(byte) + " = " + bin(byte))
    # print("div:  " + str(bin_len(div)) + " : " + str(div) + " = " + bin(div))
    # print(bin_len(255))

    # while byte:
    #     pass

Exemple #2
0
from utils.control_bit import get_control_bit
from utils.crc import get_crc_from_file
from utils.modulo_sum import get_modulo_sum_from_file
from utils.noise import set_noise_in_file

if __name__ == '__main__':
    file_path = "files/files_to_test/test.jpg"
    crc_div = 78
    mod_div = 102

    file = open(file_path, "rb").read()

    ctrl_bit = get_control_bit(file)
    sum_mod = get_modulo_sum_from_file(file, mod_div)
    crc = get_crc_from_file(file, crc_div)

    print("Control bit: ", ctrl_bit)
    print("Modulo sum: ", sum_mod)
    print("CRC: ", crc)

    print("\nAdding noises...")
    file = set_noise_in_file(file, 0.0001)
    print("Added noises...\n")

    new_ctrl_bit = get_control_bit(file)
    new_sum_mod = get_modulo_sum_from_file(file, mod_div)
    new_crc = get_crc_from_file(file, crc_div)

    print("New control bit: ", new_ctrl_bit, ", old:", ctrl_bit)
    print("New modulo sum: ", new_sum_mod, ", old: ", sum_mod)
    print("New CRC: ", new_crc, ", old: ", crc, ". Checked with prev CRC: ", get_crc_from_file(file, crc_div, crc))