Questions tagged [hashlib]

Hashlib is a Python module that implements a common interface to many different secure hash and message digest algorithms.

427 questions
5
votes
1 answer

Hash function that protects against collisions, not attacks. (Produces a random UUID-size result space)

Using SHA1 to hash down larger size strings so that they can be used as a keys in a database. Trying to produce a UUID-size string from the original string that is random enough and big enough to protect against collisions, but much smaller than the…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
4
votes
2 answers

Why is Python's Hashlib not strongly typed?

Python is supposed to be strongly typed. For instance: 'abc'['1'] won't work, because you're expected to provide an integer there, not a string. An error wil be raised and you can go on and correct it. But that's not the case with hashlib. Indeed,…
Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116
4
votes
2 answers

Why can't I install hashlib with pip in python 3 for Windows?

I tried without success to install hashlib in python 3 for windows with pip. Collecting hashlib Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip ERROR:…
Tarniadi
  • 79
  • 1
  • 1
  • 4
4
votes
2 answers

Errors running gcloud, was working fine till yesterday

Yesterday, gcloud was working completely fine. And today, it's throwing this error. I'm quite sure I haven't changed anything to cause this. Does anybody have any idea what this could be? 1) I've exported CLOUDSDK_PYTHON to be the python2 path. I…
DUDANF
  • 2,618
  • 1
  • 12
  • 42
4
votes
1 answer

Is it safe to store sha256 hash of the original unencripted file that is to be stored in encrypted form?

I am working on a document management system and in order to detect changes in files/duplicates of files I am using sha256 to get the digests for comparison. This is being done in python. The system can be configured to encrypt the files before…
4
votes
1 answer

Why is hashlib so faster than other codes for sha256 and how can I get my code close to hashlib performance?

Bellow is a code that compares hashlib.sha256() to my sha256_test() function which is written in raw python in terms of hash rate performance. from time import time_ns as time import hashlib def pad512(bytes_): L = len(bytes_)*8 K …
PouJa
  • 180
  • 4
  • 13
4
votes
2 answers

_sha import in python hashlib

Well, today I was checking the hashlib module in python, but then I found something that I still can't figure out. Inside this python module, there is an import that I can't follow. I goes like this: def __get_builtin_constructor(name): if name…
FernandoEscher
  • 2,940
  • 2
  • 28
  • 27
4
votes
1 answer

Using hashlib.sha256 to create a unique id; is this guaranteed to be unique?

I am trying to create a unique record id using the following function: import hashlib from base64 import b64encode def make_uid(salt, pepper, key): s = b64encode(salt) p = b64encode(pepper) k = b64encode(key) return hashlib.sha256(s + p +…
mwkrimson
  • 115
  • 1
  • 9
4
votes
1 answer

Why I am getting this error(AttributeError: 'module' object has no attribute 'openssl_md_meth_names')?

So far there seems to be only one question regarding this error in the entire forum.. When running any pyo example in E-Pyo through Python 2.7.11 I get this error: File "C:\Python27\lib\site-packages\pyolib\_core.py", line 22, in import…
4
votes
1 answer

Seed numpy.random.RandomState with hashlib hash

I want to seed numpy.random.RandomState instance with an hashlib generated hash to have pseudorandom source always generating same values for same input data. When I try to do that this way: hash =…
jaboja
  • 2,178
  • 1
  • 21
  • 35
4
votes
2 answers

Is there any way to use non-openssl md5 for hashlib in python?

I generate md5 content hashes for upload verification, but it has recently come to my attention that this will fail for any users running on a FIPS enabled machine. FIPS disables openssl md5, resulting in a ValueError when I try to initialize…
Jordon Phillips
  • 14,963
  • 4
  • 35
  • 42
4
votes
2 answers

unsupported hash type when installing plone

I tried to install plone but I have a problem when I run the script install.sh. Here are the errors details: raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not…
user1499220
  • 419
  • 4
  • 12
  • 23
4
votes
3 answers

Remove all characters from a string who's ordinals are out of range

What is a good way to remove all characters that are out of the range: ordinal(128) from a string in python? I'm using hashlib.sha256 in python 2.7. I'm getting the exception: UnicodeEncodeError: 'ascii' codec can't encode character u'\u200e' in…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
3
votes
4 answers

Combine (3) 32-char hex hashes into a single unique 32-char hash?

I have (3) md5sums that I need to combine into a single hash. The new hash should be 32-characters, but is case-sensitive and can be any letter or number. What's the best way to do this in Python?
ensnare
  • 40,069
  • 64
  • 158
  • 224
3
votes
2 answers

Porting hashs from php's crypt() to python

I was wondering if there is a python cognate to PHP's crypt() function that performs in a similar way, generating a random salt and embedding it within the saved string. I have a table of hashed passwords that were created using the $5$ string key…
DeaconDesperado
  • 9,977
  • 9
  • 47
  • 77