diff options
author | Yigit Sever | 2021-04-16 14:41:35 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-16 14:41:35 +0300 |
commit | 45d98cdbf95580ea7e21d17a0518993fe23914a0 (patch) | |
tree | b48baf4608325dd536d07cb5fd68684f9f047586 /scripts | |
parent | 109ae1f771ec5e8a5a9510c3b09fad579dab5ed7 (diff) | |
download | gradecoin-45d98cdbf95580ea7e21d17a0518993fe23914a0.tar.gz gradecoin-45d98cdbf95580ea7e21d17a0518993fe23914a0.tar.bz2 gradecoin-45d98cdbf95580ea7e21d17a0518993fe23914a0.zip |
Passing auth test
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/encryptor.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/encryptor.py b/scripts/encryptor.py index 008ac51..2dac487 100644 --- a/scripts/encryptor.py +++ b/scripts/encryptor.py | |||
@@ -20,16 +20,28 @@ cipher = Cipher(algorithms.AES(key), mode) | |||
20 | 20 | ||
21 | encryptor = cipher.encryptor() | 21 | encryptor = cipher.encryptor() |
22 | 22 | ||
23 | padder = padding.PKCS7(128).padder() | ||
24 | 23 | ||
25 | payload_string = """{"public_key":"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzJN9ALFoUHE8SigFhtql | 24 | payload = dict() |
26 | \\n+GPI6dIVHDCfAFXe6DU131yXoL14imBRBb5SevMou5WGiL7XBTdtlRaY8+dkNdFz\\nWEMhPoe++/GvV3u6Mq6UAJMjuiJj838NbJVl+83+NEP66htXpqidTIdr | 25 | payload["public_key"] = """-----BEGIN PUBLIC KEY----- |
27 | 7syaRU1T\\n0PfgvVYdNkwiWkTVtwveRchGtUwp2iZePMSF1+vtKKDvzXgZuwrKBhwBFXz6ApSZ\\n+eGkWhK1pW6TRTSENlySwb/DEg5PckzOzApLTTQqi4uu+sHU | 26 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoNsLhsQzL+5HiGuaI4mu |
28 | D+McAtOP9pNILwst\\nG87LxNEO0roFqUaDIhRolgkF8jol2BUZmKChdy84XX+L6jpqDvPsxuTUpIghr0Jq\\nvQIDAQAB\\n-----END PUBLIC KEY-----","st | 27 | K0TqiLEOFPOl8kd9pWR8eop0b7/N2ggDRXATIkV+XwzeQp+k9lGT1h2B2bDhxn51 |
29 | udent_id":"e223795","passwd":"pmcTCKox99NFsqp"}""" | 28 | lBESb2rSqKKzTVf4SXoPxqvPwsi1bnmHcRG8tTr+ZWcJdblXabMUkKUJCrwKhvr8 |
29 | UpOi0tndcc7buVq4EWCIBUeG4SCFHeBu1Ue9Zus7BpwjSxF4jHH4M8ssl/ioN8+m | ||
30 | qz9LcDQe3kvVRMlVbaXjYnWyP0VjwRbQuwIjMsDVaTQUIVtPZY9el7LiIxCqZ4mO | ||
31 | cnnwlIZyGLN52uqDZ1cz7aSO18YIGcbCpxuOuPhSzrnZNvHJZFIkacd477fK+PKB | ||
32 | 7QIDAQAB | ||
33 | -----END PUBLIC KEY-----""" | ||
34 | payload["student_id"] = "e223795" | ||
35 | payload["passwd"] = "pmcTCKox99NFsqp" | ||
36 | |||
37 | import json | ||
38 | payload_string = json.dumps(payload) | ||
30 | 39 | ||
31 | byte_guys = str.encode(payload_string) | 40 | byte_guys = str.encode(payload_string) |
41 | |||
42 | padder = padding.PKCS7(128).padder() | ||
32 | padded_data = padder.update(byte_guys) | 43 | padded_data = padder.update(byte_guys) |
44 | padded_data += padder.finalize() | ||
33 | 45 | ||
34 | ct = encryptor.update(padded_data) + encryptor.finalize() | 46 | ct = encryptor.update(padded_data) + encryptor.finalize() |
35 | 47 | ||