Created
July 3, 2013 08:24
-
-
Save soul0592/5916337 to your computer and use it in GitHub Desktop.
Cliente RSA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rsa import public,e,d,cifrar,decifrar | |
from sys import argv | |
import socket | |
def main(): | |
socket1 = socket.socket() | |
print "Servidor iniciando..." | |
socket1.connect(("localhost", 9999)) | |
(publica,privada) = public(int(argv[1])) | |
recibido = socket1.recv(512) | |
print recibido | |
resp = e(int(recibido), privada) | |
print resp | |
socket1.send(str(resp)) | |
conexion = socket1.recv(512) | |
print conexion | |
if conexion == "Conectado": | |
print "Conectado." | |
plaintxt = raw_input("Introducir mensaje: ") | |
cyphertxt = e(cifrar(plaintxt),publica) | |
socket1.send(str(cyphertxt)) | |
print 'Mensaje enviado y cifrado: ', cyphertxt | |
else: | |
print "Error de conexion." | |
print "Conexion terminada." | |
socket1.close() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment