mirror of
https://github.com/markqvist/Reticulum.git
synced 2025-07-22 22:40:58 -04:00
Added python-only fallback for SHA-256 and SHA-512
This commit is contained in:
parent
86061f9f47
commit
c46b98f163
4 changed files with 240 additions and 3 deletions
|
@ -1,4 +1,18 @@
|
|||
import hashlib
|
||||
import importlib
|
||||
if importlib.util.find_spec('hashlib') != None:
|
||||
import hashlib
|
||||
else:
|
||||
hashlib = None
|
||||
|
||||
if hasattr(hashlib, "sha512"):
|
||||
from hashlib import sha512 as ext_sha512
|
||||
else:
|
||||
from .SHA512 import sha512 as ext_sha512
|
||||
|
||||
if hasattr(hashlib, "sha256"):
|
||||
from hashlib import sha256 as ext_sha256
|
||||
else:
|
||||
from .SHA256 import sha256 as ext_sha256
|
||||
|
||||
"""
|
||||
The SHA primitives are abstracted here to allow platform-
|
||||
|
@ -8,13 +22,13 @@ calls in RNS end up here.
|
|||
"""
|
||||
|
||||
def sha256(data):
|
||||
digest = hashlib.sha256()
|
||||
digest = ext_sha256()
|
||||
digest.update(data)
|
||||
|
||||
return digest.digest()
|
||||
|
||||
def sha512(data):
|
||||
digest = hashlib.sha512()
|
||||
digest = ext_sha512()
|
||||
digest.update(data)
|
||||
|
||||
return digest.digest()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue