mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Fix deprecation warnings
This commit is contained in:
@ -59,7 +59,7 @@ class EbouticTest(TestCase):
|
||||
with open("./eboutic/tests/public_key.pem") as f:
|
||||
settings.SITH_EBOUTIC_PUB_KEY = f.read()
|
||||
privkey = crypto.load_privatekey(crypto.FILETYPE_PEM, PRIVKEY)
|
||||
sig = crypto.sign(privkey, query, "sha1")
|
||||
sig = crypto.sign(privkey, query.encode("utf-8"), "sha1")
|
||||
b64sig = base64.b64encode(sig).decode("ascii")
|
||||
|
||||
url = reverse("eboutic:etransation_autoanswer") + "?%s&Sig=%s" % (
|
||||
|
@ -14,11 +14,11 @@ with open("./private_key.pem") as f:
|
||||
with open("./public_key.pem") as f:
|
||||
PUBKEY = f.read()
|
||||
|
||||
string = "Amount=400&BasketID=4000&Auto=42&Error=00000\n"
|
||||
data = "Amount=400&BasketID=4000&Auto=42&Error=00000\n".encode("utf-8")
|
||||
|
||||
# Sign
|
||||
prvkey = crypto.load_privatekey(crypto.FILETYPE_PEM, PRVKEY)
|
||||
sig = crypto.sign(prvkey, string, "sha1")
|
||||
sig = crypto.sign(prvkey, data, "sha1")
|
||||
b64sig = base64.b64encode(sig)
|
||||
print(b64sig)
|
||||
|
||||
@ -28,7 +28,7 @@ cert = crypto.X509()
|
||||
cert.set_pubkey(pubkey)
|
||||
sig = base64.b64decode(b64sig)
|
||||
try:
|
||||
crypto.verify(cert, sig, string, "sha1")
|
||||
crypto.verify(cert, sig, data, "sha1")
|
||||
print("Verify OK")
|
||||
except:
|
||||
print("Verify failed")
|
||||
|
@ -264,7 +264,7 @@ class EtransactionAutoAnswer(View):
|
||||
crypto.verify(
|
||||
cert,
|
||||
sig,
|
||||
"&".join(request.META["QUERY_STRING"].split("&")[:-1]),
|
||||
"&".join(request.META["QUERY_STRING"].split("&")[:-1]).encode("utf-8"),
|
||||
"sha1",
|
||||
)
|
||||
except:
|
||||
|
Reference in New Issue
Block a user