Use more straightforward calls of hashlib.sha1/sha256

This commit is contained in:
Lonami Exo
2017-06-02 16:49:03 +02:00
parent 6b4f2abb96
commit 153cbfd350
5 changed files with 25 additions and 32 deletions

View File

@@ -1,3 +1,5 @@
from hashlib import sha1
from .. import helpers as utils
from ..utils import BinaryReader, BinaryWriter
@@ -6,7 +8,7 @@ class AuthKey:
def __init__(self, data):
self.key = data
with BinaryReader(utils.sha1(self.key)) as reader:
with BinaryReader(sha1(self.key).digest()) as reader:
self.aux_hash = reader.read_long(signed=False)
reader.read(4)
self.key_id = reader.read_long(signed=False)

View File

@@ -1,6 +1,6 @@
import os
from hashlib import sha1
from .. import helpers as utils
from ..utils import BinaryWriter
@@ -19,7 +19,7 @@ class RSAServerKey:
with BinaryWriter() as writer:
# Write SHA
writer.write(utils.sha1(data[offset:offset + length]))
writer.write(sha1(data[offset:offset + length]).digest())
# Write data
writer.write(data[offset:offset + length])
# Add padding if required