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 {})') #Encrypt the file ecprint('Encrypting file...', color='blue') ecprint([args.block, args.key, ''.join(['*' for _ in passwd])], color='yellow', template= 'Using : \n\tSymetric block: {}\n\tPublic key: {}\n\tPassword: {}') g.encrypt(passwd, args.key, selected_block=args.block, fast=args.fast) #Save the file ecprint('Saving file...', color='blue') g.save(args.outfile, authfile=args.auth) ecprint(args.outfile, color='blue', template='File saved at {}') if (args.auth is not None): ecprint(args.auth, color='blue', template='Authfile saved at {}')
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() g.save('testfile.enc') e = dt.now() ecprint(['Escritura de fichero ', str(e - s)], color=['cyan', 'yellow'], template='{} : {}') #DECRYPT #g = Giltzarrapo(n_processes = num_process) g = Giltzarrapo() #read cprint('Leyendo fichero...', color='cyan', end='\r') s = dt.now() g.readEncrypted('testfile.enc') e = dt.now() ecprint(['Lectura de fichero ', str(e - s)], color=['cyan', 'yellow'],
if args.auth is not None: ecprint(args.auth, color='yellow', template='Using auth file : {}') g.readEncrypted(args.infile, authfile=args.auth) ecprint(len(g.blocks), color='yellow', template='Blocks to decrypt: {}') #Find the symetric block (this step is automatically done in the decryption if the block is not provided) if args.block is None: ecprint('Finding the symetric block...', color='blue') args.block = g.findBlock(passwd, args.privkey, passphrase) ecprint(args.block, color='yellow', template='Symetric block found: {}') else: ecprint(args.block, color='yellow', template='Preselected symetric block: {}') #Decrypt the file ecprint('Decrypting file...', color='blue') ecprint( [args.block, args.privkey, ''.join(['*' for _ in passwd])], color='yellow', template= 'Using : \n\tSymetric block: {}\n\tPrivate key: {}\n\tPassword: {}') g.decrypt(passwd, args.privkey, passphrase, selected_block=args.block) #Save the file ecprint('Saving file...', color='blue') g.save(args.outfile) ecprint(args.outfile, color='blue', template='File saved at {}')