Questions tagged [message-digest]
131 questions
66
votes
2 answers
What's the difference between Message Digest, Message Authentication Code, and HMAC?
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…

zer0stimulus
- 22,306
- 30
- 110
- 141
44
votes
3 answers
Need thread safe MessageDigest in Java
I need to hash multiple keys from multiple threads using MessageDigest in a performance critical environment. I came to know that MessageDigest is not thread safe as it stores its state in it's object. What can be the best possible way to achieve…

Anil Padia
- 513
- 1
- 6
- 12
39
votes
4 answers
Does every Android phone support SHA-256
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…

joshkendrick
- 3,497
- 8
- 38
- 52
20
votes
6 answers
When is it safe to use a broken hash function?
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…

rook
- 66,304
- 38
- 162
- 239
12
votes
2 answers
How can I use Java MD5 MessageDigest without catching NoSuchAlgorithmException?
In Java, if I want to compute an MD5 sum, I need to be aware of possible exceptions:
try {
MessageDigest md = MessageDigest.getInstance("MD5");
// Do stuff
} catch (NoSuchAlgorithmException e) {
// Can't happen...
}
However, according to…

MikeD
- 3,348
- 1
- 23
- 36
11
votes
1 answer
What does MessageDigest.update(byte[]) do?
What exactly does this do? I tried to look it up but didn't find anything.
Reason for asking is I want to incorporate a SALT byte[] into a value which is then hashed. So should it be done like this (Pseudo…

LuckyMe
- 3,820
- 2
- 27
- 35
9
votes
3 answers
will java messagedigest generated different MD5 hash on different jdk version?
I am using java message digest to create MD5 hash, which is used for authentication. The MD5 hash is stored in the database as varchar2. I did a test to create a user on my tomcat server on my local laptop. When I deployed the war to the test tomcat…

sse
- 1,151
- 2
- 14
- 26
9
votes
3 answers
why is hash output fixed in length?
Hash functions always produce a fixed length output regardless of the input (i.e. MD5 >> 128 bits, SHA-256 >> 256 bits), but why?
I know that it is how the designer designed them to be, but why they designed the output to have the same length?
So…

Alvida
- 145
- 1
- 1
- 9
8
votes
2 answers
Is MD5 guaranteed to be available for use with MessageDigest in Android?
I want to know if the MD5 digest algorithm is guaranteed to be available in all Android devices before I bluntly ignore the checked exception that MessageDigest.getInstance("MD5") can throw.

Daniel
- 2,728
- 3
- 21
- 33
8
votes
1 answer
How is md5Hash calculated for com.google.appengine.api.blobstore.BlobInfo
We're trying to avoid saving duplicate files. However, our md5 result is always different from BlobInfo.
How we calculate it:
MessageDigest messageDigest = java.security.MessageDigest.getInstance("MD5");
digest =…

Tom Fishman
- 1,716
- 6
- 22
- 36
6
votes
6 answers
construct a unique number for a string in java
We have a requirement of reading/writing more than 10 million strings into a file. Also we do not want duplicates in the file. Since the strings would be flushed to a file as soon as they are read we are not maintaining it in memory.
We cannot use…

praveen
- 231
- 2
- 11
6
votes
4 answers
c# fast hash calculation
I'm looking for a c# wrapper to a native MD5 or SHA1 library to improve hash calculation performance.
Previously I switched SharpZipLib to zlib and got more than 2x performance boost. (ok, you've to take care you've the right zlib.so or zlib.dll…

pablo
- 6,392
- 4
- 42
- 62
5
votes
2 answers
When to use MessageDigest.reset()
I've blindly followed OWASP's recommendation on hash generation in java (see here), and I'm not sure I've done it correctly. Specifically, I'm unsure about the purpose and effect of MessageDigest.reset(), and therefore when and how to use it.
I'm…

Hank
- 4,597
- 5
- 42
- 84
4
votes
3 answers
Update checksum (MD5, SHA1) when append files java
Is it possible to update the checksum (MD5, SHA1) when we have Hash value when we append file.
I have file A already uploaded to server and i already have MD5 file which contain MD5 hash value.
I want to append a new Data block (byte[]) to the file…

TuanNN
- 95
- 10
4
votes
3 answers
Hash generation using java digest gets slower in time
I'm having a real curious situation, in a production environment using wildfly 8.2 and Java 1.7.
The situation is that when the server is been up for more than 2 weeks the login begins to drop performance. I have been looking for clues that may…

A.rolo
- 93
- 10