Moved hashing to native python3 hashlib

pull/76/head
Mark Qvist 2022-06-07 12:51:41 +02:00
rodzic 379e56b2ce
commit 715a84c6f2
2 zmienionych plików z 5 dodań i 8 usunięć

Wyświetl plik

@ -26,7 +26,6 @@ import time
import RNS
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
class Callbacks:
@ -97,10 +96,7 @@ class Destination:
name = Destination.full_name(app_name, *aspects)
# Create a digest for the destination
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
digest.update(name.encode("UTF-8"))
return digest.finalize()[:10]
return RNS.Identity.full_hash(name.encode("utf-8"))[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]
@staticmethod
def app_and_aspects_from_name(full_name):

Wyświetl plik

@ -27,9 +27,10 @@ import RNS
import time
import atexit
import base64
import hashlib
from .vendor import umsgpack as umsgpack
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
@ -158,10 +159,10 @@ class Identity:
:param data: Data to be hashed as *bytes*.
:returns: SHA-256 hash as *bytes*
"""
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
digest = hashlib.sha256()
digest.update(data)
return digest.finalize()
return digest.digest()
@staticmethod
def truncated_hash(data):