Пример #1
0
if '-e' in sys.argv:
    #RSA KEYS
    cprint('Generando claves...', color='cyan', end='\r')
    s = dt.now()
    Giltzarrapo.generateRSApair(passphrase=passph)
    e = dt.now()
    ecprint(['Generacion de claves ', str(e - s)],
            color=['cyan', 'yellow'],
            template='{} : {}')

    #ENCRYPT
    g = Giltzarrapo(n_processes=num_process)
    #read
    cprint('Leyendo fichero...', color='cyan', end='\r')
    s = dt.now()
    g.readPlain('testfile.txt')
    e = dt.now()
    ecprint(['Lectura de fichero   ', str(e - s)],
            color=['cyan', 'yellow'],
            template='{} : {}')
    #encrypt
    cprint('Cifrando fichero...', color='cyan', end='\r')
    s = dt.now()
    g.encrypt(passwd, 'giltza_rsa.pub', fast=False, selected_block=sb)
    e = dt.now()
    ecprint(['Cifrado de fichero   ', str(e - s)],
            color=['cyan', 'yellow'],
            template='{} : {}')
    #save
    cprint('Escribiendo fichero...', color='cyan', end='\r')
    s = dt.now()
Пример #2
0
    Giltzarrapo().readPlain(args.infile).encrypt(passwd,
                                                 args.key,
                                                 selected_block=args.block,
                                                 fast=args.fast).save(
                                                     args.outfile,
                                                     authfile=args.auth)
else:
    #Encrypt the file step by step
    ecprint('Starting encrypting module...', color='blue')

    #Read the file
    g = Giltzarrapo()
    ecprint([args.infile, os.path.getsize(args.infile)],
            color='yellow',
            template='Reading file : {} ({} Bytes)')
    g.readPlain(args.infile)
    ecprint(len(g.blocks), color='yellow', template='Blocks to encrypt: {}')

    #Select the symetric block (this step is automatically done in the encryption if the block is not provided)
    if args.block is None:
        ecprint('Selecting a high entropy block...', color='blue')
        args.block = g.selectBlock(tryLimit=10)
        while not g.verifySymetricBlock(args.block, args.key):
            args.block = g.selectBlock(tryLimit=10)
    else:
        ecprint('Preselected block for encryption', color='blue')
    ecprint([
        args.block, '{:.4f}'.format(Giltzarrapo.entropy(g.blocks[args.block]))
    ],
            color='yellow',
            template='Selected block: {} (entropy of {})')