Python3 was a mistake

This commit is contained in:
shim_ 2018-07-19 22:53:07 +02:00
parent d6367a72cf
commit 4a41f768c2

View File

@ -5,7 +5,7 @@ from Crypto.Util import Counter
from Crypto.PublicKey import RSA
from Crypto.PublicKey import DSA
from salsa20 import Salsa20_keystream
import os, struct, time, hashlib, hashlib, random
import os, struct, time, hashlib, hashlib, random, binascii
class EncryptedScreenshot:
@ -15,7 +15,7 @@ class EncryptedScreenshot:
random.choice("1234567890ABCDEFGHIJKLMNOPQRSTUWVXYZabcdefghijklmnopqrstuwvxyz") for _ in range(len))
self.password = rand(16)
print("Passphrase %s" % str(bytearray(self.passphrase())).encode("hex"))
print("Passphrase %s" % binascii.hexlify(self.passphrase()))
self.id = id
if id is None:
self.id = rand(8)
@ -34,7 +34,7 @@ class EncryptedScreenshot:
# new ScryptParameters(64, 8, 1,32, new Uint8List.fromList(new List<int>()))
print("Password units: %s" % (map(ord, self.password.encode("utf-8")),))
sha = hashlib.sha256()
sha.update(self.password)
sha.update(self.password.encode("utf-8"))
return sha.digest() # scrypt.hash(self.password.encode("utf-8"), '', 64, 8, 1, 32)
def assemble(self, file):
@ -51,8 +51,8 @@ class EncryptedScreenshot:
encrypted_metadata = iv + str(bytearray(encrypted_metadata))
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("%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(bson.loads(unencrypted_metadata))
@ -73,8 +73,9 @@ class EncryptedScreenshot:
def encryptor(self,length=0):
iv = os.urandom(16)
ctr = Counter.new(128, initial_value=long(iv.encode("hex"), 16))
print("IV: %s" % iv.encode("hex"))
nonce = int.from_bytes(binascii.hexlify(iv), byteorder='little')
ctr = Counter.new(128, nonce, 16)
print("IV: %s" % binascii.hexlify(iv))
cipher = AES.new(self.passphrase(), AES.MODE_CTR, counter=ctr)
#salsa