-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient_03.py
More file actions
83 lines (61 loc) · 1.86 KB
/
Client_03.py
File metadata and controls
83 lines (61 loc) · 1.86 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# random code using api
import requests
import random
import socket
import re
API_URL = "https://api-inference.huggingface.co/models/xlm-roberta-base"
headers = {"Authorization": f"Bearer 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"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# step to use here:
# The user should be giving a unique response phrase to generate the keywords
output = query({
"inputs": "<mask>",
})
passwords_keys = []
for i in output:
# print(i)
for j in i:
if j == 'sequence':
print(i[j])
x = i[j]
x = x.split(" ")
passwords_keys.append(x[0])
dictionary = "1234567890"
def key_generator(x):
lists = x
key = random.choice(lists)
print(f"The chosen key phrase was: {key}")
return key
generated_key = key_generator(passwords_keys)
key_number = 0
for i in generated_key:
location_of_string = dictionary.find(i)
key_number = location_of_string + key_number
# print(f"The final key is: {key_number}")
apiNumber = key_number
# sent to server
HOST = '127.0.0.1'
PORT = 9090
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((HOST, PORT))
client.send("Hello World\n".encode('utf-8'))
# print whatever you receive form the server
received_message = client.recv(1024).decode('utf-8')
print(received_message)
received_message = client.recv(1024).decode('utf-8')
print(received_message)
some_string = received_message
num = re.findall(r'\d+', some_string)
s = [str(i) for i in num]
num = str("".join(s))
num = num[2:-4]
num = int(num)
# apiNumber = (int(apiNumber) ** float(num))
print(f"number is {num}")
lists = received_message.split(" ")
print(lists)
generated_seed = apiNumber + num
print(f"This is the generated seed: {generated_seed}")
client.send(f"{generated_seed}".encode('utf-8'))