elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Necesito ayuda con PyCrypto
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Necesito ayuda con PyCrypto  (Leído 1,586 veces)
Th3_K1d

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Necesito ayuda con PyCrypto
« en: 10 Noviembre 2017, 01:47 am »

Hola, hace unos días me topé con este código en python que cifra archivos con claves AES usando el módulo PyCrypto, el problema es que no encuentro forma de hacer un código que decifre el archivo, si alguien me pudiese ayudar lo agradecería.

Uso python 2.7.13.

Código:
# -*- coding: utf8 -*-
import os, fnmatch, struct, random, string, base64, platform, sys, time, socket, json, urllib, ctypes, urllib
from Crypto import Random
from Crypto.Cipher import AES

KEY = ''.join([ random.choice(string.ascii_letters + string.digits) for n in xrange(32) ])

def encrypt(key, in_filename, newfilename, out_filename = None, chunksize = 65536, Block = 16):
    if not out_filename:
        out_filename = newfilename
    iv = Random.new().read(AES.block_size)
    encryptor = AES.new(key, AES.MODE_CBC, iv)
    filesize = os.path.getsize(in_filename)
    with open(in_filename, 'rb') as infile:
        with open(out_filename, 'wb') as outfile:
            outfile.write(struct.pack('<Q', filesize))
            outfile.write(iv)
            while True:
                chunk = infile.read(chunksize)
                if len(chunk) == 0:
                    break
                elif len(chunk) % 16 != 0:
                    chunk += ' ' * (16 - len(chunk) % 16)
                outfile.write(encryptor.encrypt(chunk))


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Necesito ayuda, por favor, necesito eliminar definitivamente un contacto del msn « 1 2 »
Mensajería
jordijor 10 14,341 Último mensaje 19 Diciembre 2011, 09:16 am
por A4TECH
Necesito su ayuda,NECESITO CONSEJOS PARA PROGRAMAR,MI VIDA DEPENDE D ESTO
Desarrollo Web
nevermind2403 7 5,763 Último mensaje 25 Septiembre 2013, 03:53 am
por Graphixx
[Python] ayuda con pycrypto « 1 2 »
Scripting
Pois0n84 10 6,413 Último mensaje 21 Agosto 2016, 03:19 am
por Pois0n84
Hola amigos Necesito su ayuda con este codigo necesito pasarlo de C++ A C# ayuda
Programación C/C++
ManicaHere 0 3,197 Último mensaje 1 Diciembre 2016, 05:29 am
por ManicaHere
Instalar pycrypto en ubuntu 14
Seguridad
maria13 1 2,727 Último mensaje 2 Mayo 2018, 11:36 am
por aangrymasther
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines