Example #1
0
def subcarriersFromBits(bits, rate, scramblerState):
    # scrambled includes tail & padding
    scrambled = scrambler.scramble(bits, rate.Nbps, scramblerState=scramblerState)
    coded = code.encode(scrambled)
    punctured = code.puncture(coded, rate.puncturingMatrix)
    interleaved = interleaver.interleave(punctured, rate.Ncbps, rate.Nbpsc)
    mapped = qam.encode(interleaved, rate)
    return mapped.reshape(mapped.size/ofdm.format.Nsc, ofdm.format.Nsc)
Example #2
0
def main(security_token_file=SECURITY_TOKEN_FILE, interval=INTERVAL):

# Creating logger
    logger = logging.getLogger('twitter-bot-logger')
    logger.setLevel(logging.DEBUG)

# Creating file handler
    filehandler = logging.FileHandler(LOGFILE)
    filehandler.setLevel(logging.DEBUG)

# Create a formatter (ToDo: Add new style formatter)
    formatted=logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    filehandler.setFormatter(formatted)

# Add handler to logger
    logger.addHandler(filehandler)

#   Main Code

    tokens=lt.load_tokens(security_token_file)
    logger.debug('Tokens loaded')

    bot=twitter_bot.create_bot(
                               (
                               tokens['OAUTH_TOKEN'],
                               tokens['OAUTH_SECRET'],
                               tokens['CONSUMER_KEY'],
                               tokens['CONSUMER_SECRET']
                               )
                              )

    logger.debug('Bot created')

    last_ip=''
    while True:
        current_ip=get_ip.get_ip()
        logger.debug('Current ip obtained. IP is {0}'.format(current_ip))
        if not current_ip==last_ip:
            logger.debug('Posting ip to twitter.')
            last_ip=current_ip
            scrambled=scrambler.scramble(current_ip)

# This part posts the ip on twitter. I have disabled it in favour of sending
# direct messages
#            twitter_bot.post_status(bot,scrambled)
            
            logger.debug('Sending dm to {}'.format(RECIPIENT))
            logger.debug(scrambled)
            
            twitter_bot.message_user(bot,RECIPIENT, scrambled)

        else:
            logger.debug('IP not changed.')
            logger.debug('Current ip is {}'.format(current_ip))
            logger.debug('Last ip was {}'.format(last_ip))

        logger.debug('Sleeping for {} seconds'.format(INTERVAL))
        time.sleep(INTERVAL)
Example #3
0
def acConnect(dom):
    global workbook

    dom.inner("", open("Main.html").read())

    dom.setValue("output", "Opening workbook (may take some time)…")
    dom.removeClass("output", "hidden")

    workbook = openpyxl.load_workbook("produceSales.xlsx")

    dom.setValue("output", "Scrambling…")
    scrambler.scramble(workbook)

    dom.setValue("output", "Displaying…")
    display(dom)

    dom.setValue("output", "Done.")
    dom.addClass("output", "hidden")
    def __init__(self, signal, algorythm, now):
        print("String: ")
        napis = ""
        print(type(signal))
        for x in range(len(signal)):
            napis += str(signal[x])
        print(napis)

        if (algorythm == "AES"):
            napis = ""
            for x in range(len(signal)):
                napis += str(signal[x])
                if (signal[x] == 0):
                    napis += "0"
            print(napis)
            print(type(napis))
            key = random.randint(0x00, 0xFF)
            cipher = AES2.AES(key)
            print(type(napis))
            encrypted = cipher.encrypt(napis)
            decrypted = cipher.decrypt(encrypted)
            print(decrypted)

        else:
            pure_disrupted = distrupter.distruption2(
                signal,
                algorythm)  # zaklocenie sygnalu wysylanego bez scramblera
            scrambled = scrambler.scramble(
                signal, algorythm)  # zescramblowanie sygnalu
            tab1 = list(receiver.signalhistogram(scrambled).keys())
            tab2 = list(receiver.signalhistogram(scrambled).values())
            scrambled_disrupted = distrupter.distruption(
                scrambled,
                algorythm)  # zaklocenie sygnalu wysylanego ze scramblerem
            descrambled = descrambler.descramble(
                scrambled_disrupted, algorythm
            )  # odsramblowanie sygnalu zakloconego wysylanego ze scramblerem
            receiver.receiver(
                signal, pure_disrupted, descrambled, algorythm, scrambled,
                scrambled_disrupted, tab1, tab2,
                now)  # przekazanie sygnalow do programu odbiorczego
Example #5
0
def activate_session(user):
	scramble = scrambler.scramble()
	redis_taco.set(scramble,str(user["_id"]))
	redis_taco.expire(scramble,SESSION_LENGTH)
	return scramble
Example #6
0
        if not find_line_in_file(ref_name, line, index):
            print('Line "{}" does not exists in the reference file!'
                  .format(line.strip("\n")))
            return False
    
    return True

if __name__ == "__main__":
    scramble_in_file = "test_s_input.txt"
    scramble_out_file = "test_s_output.txt"
    descramble_in_file = "test_d_input.txt"
    descramble_out_file = "test_d_output.txt"

    print("Scrambling file {} into {}...".format(scramble_in_file, 
                                                 scramble_out_file))
    scrambler.scramble(scramble_in_file , scramble_out_file )

    if test_scrambler_output(scramble_in_file, scramble_out_file):
        print("Scrambler basic test Passed!")
    else:
        print("Scrambler basic test Failed!")

    print("Descrambling file {} into {}..."
          .format(scramble_out_file, descramble_out_file))
    descrambler.descramble(descramble_in_file, descramble_out_file)

    if filecmp.cmp(scramble_in_file, descramble_out_file):
        print("Descrambler basic test Passed!")
    else:
        print("Descrambler basic test Failed!")
    with open(scramble_in_file) as infile:
Example #7
0
# Cryptic.py
# Encrypt The Discord Token by Running This Program
# Authors: jchisholm204
# Date: July 7, 2021

import os
import scrambler

# Variable for storage of the Token
discordToken = "5amp1e.d15c0rd.t0k3n"

# Use the Scramble Function to Encrypt the Token
CrypticToken = scrambler.scramble(discordToken)

# Check to see the token UnEncrypts
Token = scrambler.parse(CrypticToken)

print(f"TOKEN:\n{Token}\nCrypticToken:\n{CrypticToken}\nUnEncrypts:")
print(Token==discordToken)
Example #8
0
def decodeFromLLR(llr, length_bits):
    scrambled_bits = code.decode(llr, length_bits+16)
    return scrambler.scramble(scrambled_bits, None, scramblerState=0x5d)[:length_bits+16]
Example #9
0
 j = ncp
 i = 0
 initializedPlot = False
 length_symbols = 0
 while input.size-j > nfft and i <= length_symbols:
     sym = np.fft.fft(input[j:j+nfft])*G
     data = sym[ofdm.format.dataSubcarriers]
     pilots = sym[ofdm.format.pilotSubcarriers] * next(pilotPolarity) * ofdm.format.pilotTemplate
     kalman_u = kalman_state.update(np.sum(pilots))
     data *= kalman_u
     pilots *= kalman_u
     if i==0: # signal
         signal_bits = data.real>0
         signal_bits = interleaver.interleave(signal_bits, ofdm.format.Nsc, 1, reverse=True)
         scrambled_plcp_estimate = code.decode(signal_bits*2-1, 18)
         plcp_estimate = scrambler.scramble(scrambled_plcp_estimate, int(ofdm.format.Nsc*.5), scramblerState=0)
         parity = (np.sum(plcp_estimate) & 1) == 0
         if not parity:
             return None, None, 0
         plcp_estimate = util.shiftin(plcp_estimate[:18], 18)[0]
         try:
             encoding_estimate = util.rev(plcp_estimate & 0xF, 4)
             rate_estimate = [r.encoding == encoding_estimate for r in wifi_802_11_rates].index(True)
         except ValueError:
             return None, None, 0
         r_est = wifi_802_11_rates[rate_estimate]
         Nbpsc, constellation_estimate = r_est.Nbpsc, r_est.constellation
         Ncbps, Nbps = r_est.Ncbps, r_est.Nbps
         length_octets = (plcp_estimate >> 5) & 0xFFF
         length_bits = length_octets * 8
         length_coded_bits = (length_bits+16+6)*2
Example #10
0
def main():
    pygame.init()
    screen = pygame.display.set_mode(SCREEN_RES)
    clock = pygame.time.Clock()

    times = load()

    start_time = 0
    end_time = 0

    ready = False
    going = False
    finishing = False

    scr = scramble()

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                exit()

        keys = pygame.key.get_pressed()

        if keys[pygame.K_ESCAPE]:
            exit()

        if keys[pygame.K_SPACE]:
            if not ready and not going and not finishing:
                ready = True
            elif going:
                going = False
                finishing = True
                save(end_time - start_time)
                times.append(end_time - start_time)
                scr = scramble()
        elif ready:
            ready = False
            going = True
            start_time = time.time()
        elif finishing:
            finishing = False

        if going:
            end_time = time.time()

        color = (255, 255, 255)
        if ready:
            color = (255, 0, 0)
        elif going:
            color = (0, 255, 0)
        elif finishing:
            color = (0, 0, 255)

        pygame.draw.rect(screen, (0,0,0), (0,0,screen.get_width(), screen.get_height()))

        draw_background(screen, times[-NUMBER_DATAPOINTS_GRAPHED_MAX:])

        text = pygame.font.Font(None, 150).render("{0:.2f}".format(end_time - start_time),
                                                 1, color)
        screen.blit(text, (int(640 / 2 - 75), int(480 / 2 - 75)))

        if not going:
            text = pygame.font.Font(None, 25).render("{}".format(scr),
                                                     1, (255,255,255))
            screen.blit(text, (0, 0))

        if len(times) > 0 and (not going or ready):
            text = pygame.font.Font(None, 50).render("min: {0:.2f}".format(min(times)),
                                                     1, (255,255,255))
            screen.blit(text, (50, 350))
            
            text = pygame.font.Font(None, 50).render("avg-5: {0:.2f}".format(avg(times[-5:])),
                                                     1, (255,255,255))
            screen.blit(text, (50, 400))
            
            text = pygame.font.Font(None, 50).render("avg-12: {0:.2f}".format(avg(times[-12:])),
                                                     1, (255,255,255))
            screen.blit(text, (350, 350))

            text = pygame.font.Font(None, 50).render("n: {}".format(len(times)),
                                                     1, (255,255,255))
            screen.blit(text, (350, 400))

        clock.tick(60)
        pygame.display.update()