message-digest

How to set MessageDigest seed?

你说的曾经没有我的故事 提交于 2019-12-06 12:01:51
The MessageDigest class implements the SHA-1 algorithm (among many others). The SHA-1 algorithm allows one to use different "seeds" or initial digests. See SHA-1 Psuedocode The algorithm initializes variables, or the seed: Initialize variables: h0 = 0x67452301 h1 = 0xEFCDAB89 h2 = 0x98BADCFE h3 = 0x10325476 h4 = 0xC3D2E1F0 However the MessageDigest class, as described in the Online Java Manual , provides no API for setting these initial variables. In fact, it doesn't state the value of the initial variables. How can I set the initial seed for the SHA-1 algorithm? Where is an example of SHA-1

Hashing raw bytes in Python and Java produces different results

為{幸葍}努か 提交于 2019-12-05 04:10:40
问题 I'm trying to replicate the behavior of a Python 2.7 function in Java , but I'm getting different results when running a (seemingly) identical sequence of bytes through a SHA-256 hash. The bytes are generated by manipulating a very large integer (exactly 2048 bits long) in a specific way (2nd line of my Python code example). For my examples, the original 2048-bit integer is stored as big_int and bigInt in Python and Java respectively, and both variables contain the same number. Python2 code I

What's the difference between Message Digest, Message Authentication Code, and HMAC?

前提是你 提交于 2019-12-04 07:26:18
问题 My understanding of a message digest is that it's an encrypted hash of some data sent along with the encrypted data so you may verify that the data has not been tampered with. What is the difference then between this and message authentication codes (MAC) and hash MACs (HMAC)? 回答1: A message digest algorithm takes a single input -- a message -- and produces a "message digest" (aka hash) which allows you to verify the integrity of the message: Any change to the message will (ideally) result in

Hashing raw bytes in Python and Java produces different results

一个人想着一个人 提交于 2019-12-03 22:17:18
I'm trying to replicate the behavior of a Python 2.7 function in Java , but I'm getting different results when running a (seemingly) identical sequence of bytes through a SHA-256 hash. The bytes are generated by manipulating a very large integer (exactly 2048 bits long) in a specific way (2nd line of my Python code example). For my examples, the original 2048-bit integer is stored as big_int and bigInt in Python and Java respectively, and both variables contain the same number. Python2 code I'm trying to replicate: raw_big_int = ("%x" % big_int).decode("hex") buff = struct.pack(">i", len(raw

What's the difference between Message Digest, Message Authentication Code, and HMAC?

和自甴很熟 提交于 2019-12-02 14:00:49
My understanding of a message digest is that it's an encrypted hash of some data sent along with the encrypted data so you may verify that the data has not been tampered with. What is the difference then between this and message authentication codes (MAC) and hash MACs (HMAC)? LukeH A message digest algorithm takes a single input -- a message -- and produces a "message digest" (aka hash) which allows you to verify the integrity of the message: Any change to the message will (ideally) result in a different hash being generated. An attacker that can replace the message and digest is fully

Generating an MD5 Hash with a char[]

☆樱花仙子☆ 提交于 2019-11-30 23:41:30
How would one go about converting a char[] password obtained using this method: char[] password = passwordInputField.getPassword(); To an MD5 Hash? Normally I would use the method below, but getBytes is only compatible with Strings: MessageDigest md = MessageDigest.getInstance("MD5"); md.update(password.getBytes()); String hashedPass = new BigInteger(1, md.digest()).toString(16); Connor NOTE: The MD5 Hashing Algorithm should never be used for password storage, as it's hashes are easily cracked. However, I will use it for simplicity. The quick/easy/UNSECURE fix would be to convert the char

Generating an MD5 Hash with a char[]

旧巷老猫 提交于 2019-11-30 18:04:29
问题 How would one go about converting a char[] password obtained using this method: char[] password = passwordInputField.getPassword(); To an MD5 Hash? Normally I would use the method below, but getBytes is only compatible with Strings: MessageDigest md = MessageDigest.getInstance("MD5"); md.update(password.getBytes()); String hashedPass = new BigInteger(1, md.digest()).toString(16); 回答1: NOTE: The MD5 Hashing Algorithm should never be used for password storage, as it's hashes are easily cracked.

When is it safe to use a broken hash function?

牧云@^-^@ 提交于 2019-11-30 12:51:57
问题 It is trivial to use a secure hash function like SHA-256, and continuing to use MD5 for security is reckless behavior. However, there are some complexities to hash function vulnerabilities that I would like to better understand. Collisions have been generated for MD4 and MD5. According to NIST, MD5 is not a secure hash function. It only takes 239 operations to generate a collision and should never be used for passwords. However SHA-1 is vulnerable to a similar collision attack in which a

Does every Android phone support SHA-256

前提是你 提交于 2019-11-30 07:53:10
So reading this post: How can I calculate the SHA-256 hash of a string in Android? and the docs: http://developer.android.com/reference/java/security/MessageDigest.html I'm curious; which phones will support SHA-256? In the docs, the line about the 'NoSuchAlgorithmException' makes me think that some phones don't support all algorithms. Before I go implementing this for an app and expecting it to work the same on all phones I want to know if anyone knows anything about this...? I find it strange that the MessageDigest class doesn't have some constants to pick the algorithm you want to use. All

When is it safe to use a broken hash function?

可紊 提交于 2019-11-30 03:14:46
It is trivial to use a secure hash function like SHA-256, and continuing to use MD5 for security is reckless behavior. However, there are some complexities to hash function vulnerabilities that I would like to better understand. Collisions have been generated for MD4 and MD5 . According to NIST, MD5 is not a secure hash function. It only takes 2 39 operations to generate a collision and should never be used for passwords . However SHA-1 is vulnerable to a similar collision attack in which a collision can be found in 2 69 operations, whereas brute force is 2 80 . No one has generated a SHA-1