This question already has an answer here:
I want to compute the SHA256 based HMAC for some
key and a
import hmach = hmac.new(b'key', b'message', 'sha256')print(h.hexdigest())
I searched and found something in NodeJS but can't do the same thing in front-end (I mean in browser of the user), which I guess I need to bundle the required library and do the stuff but could not figure out how.
I tried to write a program that generates the hashes of random 64 bit integers using the
secrets modules to generate hashes and run random numbers, respectively. But, the code is not fast enough. I know the gist of how to use C programming (not C++), and I tried to write a program, but the int and char stuff was just too hard for me. Here is an example of what I want to do:
mainand print out a string with the code.
is it possible to find a file by only inputting a hash (preferably sha256) and getting a filepath?its also ok if i can immediately delete the file.im trying to make like some sort of virus scan, i know this is not good way is but its good enough for me.
i hope is can go something like this:
hash = 'hash'path = find_file(hash, C:)print(path)
i know this is not the best explanation but i hope someone can help me out.its a school project and the time is tight.
I am trying to compare results of hashing in java and python. i have a snippet of code for java and python both giving same output for Encoding with UTF-8 but giving different(kind of ) results for Hash with sha256.
String hash = "hello" byte test = hash.getBytes();MessageDigest sha = MessageDigest.getInstance("SHA-256");byte key = sha.digest(hash.getBytes());
output: test ==> [104, 101, 108, 108, 111] key ==> [44, -14, 77, -70, 95, -80, -93, 14, 38, -24, 59, 42, -59, -71, -30, -98, 27, 22, 30, 92, 31, -89, 66, 94, 115, 4, 51, 98, -109, -117, -104, 36]
hash = "hello"test = list(bytearray(text.encode()))m = hashlib.sha256()m.update(hash.encode("UTF-8"))data = m.digest()key = list(data)
output: test ==> same as Java outputkey ==> [44, 242, 77, 186, 95, 176, 163, 14, 38, 232, 59, 42, 197, 185, 226, 158, 27, 22, 30, 92, 31, 167, 66, 94, 115, 4, 51, 98, 147, 139, 152, 36]
I know it may not be possible, but I am attempting to learn how SHA-256 hashes strings in order to attempt to try to reverse SHA-256.
NOTE: I realize that this is the most common form of security hashing and in no way am I attempting to do harmful acts with this knowledge (if I succeed).
Edit1: If possible, I'd like the SHA-256 algorithm to fit within a single .js file. I am implementing the SHA-256 into a Tampermonkey script for myself, and want to also try to learn to reverse it.