Questions tagged [hashlib]

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

427 questions
0
votes
1 answer

When using hashlib in Python, a different value returned when fetched from a database

I am using Python 3.5 and when I use hashlib.md5(), a different value is returned from a database than when a string is hashed outside. The code I am using: self.m = hashlib.md5() self.m.update(self.password.encode('utf-8')) self.passCheck =…
Ben Dent
  • 37
  • 1
  • 7
0
votes
1 answer

Trouble inserting variable in sqlite python

Im having a problem inserting a variable into sqlite3 and the variable is hashed. Here's my code: if passadefinir == passadefinir2: maindb.execute("DELETE FROM Password WHERE ID = 'not'") maindb.execute("INSERT INTO Password(ID) VALUES…
Luís Duarte
  • 39
  • 1
  • 7
0
votes
1 answer

Hashlib in Windows and Linux

I'm writing a p2p application in Python and am using the hashlib module to identify files with the same contents but different names within the network. The thing is that I tested the code that does the hash for the files in Windows (Vista), with…
Nahu
  • 1
  • 1
  • 2
0
votes
1 answer

Two users, same machine, same python installs, one can't import paramiko without UserWarning, module already imported

When running following code, user without error reports normal termination. python -c "import paramiko" User with error reports termination (note, no exception) with the…
seanmus
  • 508
  • 2
  • 15
0
votes
1 answer

Cannot install hashlib on Heroku Web Application

I am trying to deploy a python web application on Heroku which uses the hashlib module in it. I included hashlib in the 'requirements.txt' file (All modules mentioned in the file are installed by Heroku using pip) However it gives me an…
Mihir Khandekar
  • 108
  • 1
  • 16
0
votes
0 answers

javascript Base64 encoding to python

I have this line in a postman pre-script that uses javascript: var hash256 = CryptoJS.HmacSHA256(rawSignature, Secret); var hashbase64 = hash256.toString(CryptoJS.enc.Base64); im trying to convert that to a python script (2.7) and have come up with…
Pete
  • 1
  • 1
0
votes
0 answers

importing hashlib error after mac os updated

After upgrading my mac os from Captain to Sierra, I am getting following error while importing hashlib. AttributeError: 'module' object has no attribute 'openssl_md_meth_names' The library was getting successfully imported in the Captain…
0
votes
1 answer

Python hashlib and sparse files

I wanted to know how does python hashlib library treat sparse files. If the file has a lot of zero blocks then instead of wasting CPU and memory on reading zero blocks does it do any optimization like scanning the inode block map and reading only…
CodeWithPride
  • 123
  • 3
  • 14
0
votes
2 answers

How to mock MD5 hash collision

I am using a private Ubuntu server and am testing a private application I am using the Python hashlib library for generating MD5 hashes. Now I want the MD5 function always return my specific number although different input. How can I do this? Is…
Nguyen Diep
  • 85
  • 1
  • 9
0
votes
0 answers

Hashing Twitter API Keys and Tokens Using Python's hashlib

I am writing a program that parses a file and tweets lines from it. I was able to write the program but I was curious if I should hash the Keys and Tokens that Twitter provides for added security? They tell you to protect the keys because they can…
pjmorin0001
  • 79
  • 3
  • 10
0
votes
1 answer

Hashlib MemoryError in Python 3.5 but not in 2.7

I've been porting a set of Python 2.7 scripts to Python 3.5 so that I can use some libraries that aren't available in 2.7, but I'm getting MemoryError from this code that worked previously: import hashlib, functools sha2h = hashlib.sha256() with…
0
votes
0 answers

How to walk through the OS and generate a hash of every file then output into a txt file?

so I have this file to walk through the OS and generate a hash of every file using python, however I want it to output the hashes into a txt file. I have tried using: from __future__ import print_function But I cannot seem to get this to work all…
dperrie
  • 315
  • 1
  • 2
  • 11
0
votes
0 answers

How can I use Python's hashlib to generate a checksum for a directory that matches 7zip's checksum?

I've found an example online that generates a checksum by hashing the hashes of each individual file in whatever order os.path.walk() lists them (which is consistent so that's fine). I've copied the example here: def GetHashofDirs(directory,…
sgfw
  • 285
  • 2
  • 14
0
votes
2 answers

Python hashlib.sha256() digest length

I have some python code, hash_object = hashlib.sha256(b'Hello World') hex_dig = hash_object.hexdigest() cipher = AES.new(hex_dig, AES.MODE_CBC, iv) plain = cipher.decrypt( cipher ) but, I have an error - ValueError: AES key must be either 16,…
khi0227
  • 11
  • 1
  • 5
0
votes
1 answer

How to truncate a SHA256 key to emulate a 128 key in Ruby

I want to truncate a 256 key to simulate a 128 key. This is easy enough in Python with [:16] >>> hashed_master_key = hashlib.sha256(master_key).digest() >>> len(hashed_master_key) 32 >>> hashed_master_key =…
onknows
  • 6,151
  • 12
  • 65
  • 109