-
Notifications
You must be signed in to change notification settings - Fork 0
/
TAREA1_karauz_dazofeifa_Cliente.py
57 lines (51 loc) · 1.26 KB
/
TAREA1_karauz_dazofeifa_Cliente.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import socket
def iniciarCliente(host, puerto, msg_env):
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c.connect((host, puerto))
msg_rec = c.recv(1024)
print (msg_rec.decode('utf8'))
c.send(msg_env.encode('ascii'))
c.close()
def codiMsg(msg):
i = 0
j = 0
d = [4,9,3]
b = ""
c = ""
flag = True
msg = msg + "/"
c2 = 0
while flag:
c = msg[i]
if c == "/":
flag = False
return b
if c >= chr(65) and c <= chr(90):
c2 = ord(c)
c2 += d[j]
c = chr(c2)
if c > chr(90):
c2 = ord(c)
c2 -= 26
c = chr(c2)
if c < chr(65):
c2 = ord(c)
c2 = c2 - 64 + 90
c = chr(c2)
elif c == chr(32):
c = chr(126)
b += c
i += 1
if j < 2:
j += 1
else:
j=0
if __name__ == "__main__":
host = "192.168.56.1"
puerto = 44440
msg = ""
while True:
print("Digite el mensaje a enviar: ")
msg = input()
msg = codiMsg(msg)
iniciarCliente(host, puerto, msg)