fuck finally
This commit is contained in:
parent
4a41f768c2
commit
0c803ba912
@ -42,20 +42,20 @@ class EncryptedScreenshot:
|
||||
self.metadata["hash"] = image_digest
|
||||
unencrypted_metadata = bson.dumps(self.metadata)
|
||||
if len(unencrypted_metadata) % 16 != 0:
|
||||
unencrypted_metadata += ' ' * (16 - len(unencrypted_metadata) % 16)
|
||||
unencrypted_metadata += b' ' * (16 - len(unencrypted_metadata) % 16)
|
||||
(encryptor, iv) = self.encryptor(len(unencrypted_metadata))
|
||||
encrypted_metadata = []
|
||||
encrypted_metadata = b''
|
||||
|
||||
encrypted_metadata += encryptor(unencrypted_metadata)
|
||||
|
||||
encrypted_metadata = iv + str(bytearray(encrypted_metadata))
|
||||
encrypted_metadata = iv + encrypted_metadata
|
||||
|
||||
print("Metadata: %s" % str(encrypted_metadata).encode("base64").replace("\n", ""))
|
||||
#print("Metadata: %s" % str(encrypted_metadata).encode("base64").replace("\n", ""))
|
||||
#print("%s %s" % (str(encrypted_metadata[:16]).encode("hex"), str(encrypted_metadata[16:]).encode("hex")))
|
||||
#print("Unencrypted: %s" % (unencrypted_metadata.encode("hex")))
|
||||
print("Password %s" % self.password)
|
||||
#print("Password %s" % self.password)
|
||||
|
||||
print(bson.loads(unencrypted_metadata))
|
||||
#print(bson.loads(unencrypted_metadata))
|
||||
|
||||
fields = {
|
||||
"image": encrypted_image,
|
||||
@ -73,8 +73,8 @@ class EncryptedScreenshot:
|
||||
|
||||
def encryptor(self,length=0):
|
||||
iv = os.urandom(16)
|
||||
nonce = int.from_bytes(binascii.hexlify(iv), byteorder='little')
|
||||
ctr = Counter.new(128, nonce, 16)
|
||||
nonce = int(binascii.hexlify(iv), 16)
|
||||
ctr = Counter.new(128,initial_value = nonce)# initial_value = nonce)
|
||||
print("IV: %s" % binascii.hexlify(iv))
|
||||
cipher = AES.new(self.passphrase(), AES.MODE_CTR, counter=ctr)
|
||||
|
||||
@ -95,7 +95,7 @@ class EncryptedScreenshot:
|
||||
def encrypt(self, file):
|
||||
filesize = os.path.getsize(file)
|
||||
(encryptor, iv) = self.encryptor(filesize)
|
||||
binary = []
|
||||
binary = b''
|
||||
digest = hashlib.sha256()
|
||||
with open(file, 'rb') as infile:
|
||||
# binary += struct.pack('<Q', filesize)
|
||||
@ -107,7 +107,7 @@ class EncryptedScreenshot:
|
||||
pass # chunk += ' ' * (16 - len(chunk) % 16)
|
||||
digest.update(chunk)
|
||||
binary += encryptor(chunk)
|
||||
return (digest.digest(), iv + str(bytearray(binary)))
|
||||
return (digest.digest(), iv + binary)
|
||||
|
||||
from Crypto.Signature import PKCS1_v1_5
|
||||
from Crypto.Hash import SHA256
|
||||
@ -131,8 +131,8 @@ class Signer:
|
||||
def signature(self,data):
|
||||
signed = self.sign(data)
|
||||
return {"signed-hash": signed,
|
||||
"signature-algorithm": "SHA-256/%s" % unicode("RSA" if self.mode == RSA else "DSA"),
|
||||
"key-id": unicode(self.privateKeyId)
|
||||
"signature-algorithm": "SHA-256/%s" % ("RSA" if self.mode == RSA else "DSA"),
|
||||
"key-id": (self.privateKeyId)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user