Questions tagged [message-digest]

124 questions
61
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
  • 18,516
  • 28
  • 99
  • 134
37
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,287
  • 7
  • 31
  • 50
36
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
  • 433
  • 1
  • 6
  • 12
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
  • 62,960
  • 36
  • 149
  • 231
11
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,138
  • 1
  • 19
  • 36
10
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,630
  • 2
  • 24
  • 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,123
  • 2
  • 14
  • 24
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,328
  • 3
  • 17
  • 31
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 =…
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
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
  • 115
  • 1
  • 9
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,282
  • 3
  • 39
  • 59
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
4
votes
1 answer

NoSuchAlgorithm exception when using MD5

import java.security.*; MessageDigest md = MessageDigest.getInstance("MD5"); fails with NoSuchAlgorithm exception. MessageDigest docs](http://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html) say: Every implementation of the…
4
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,236
  • 5
  • 39
  • 76
1
2 3
8 9