I have a list of Integer
List<Integer> listInt;
I want to generate a MD5 hash for the listInt how should I approach the problem, I know that I have to use
MessageDigest.getInstance("MD5").digest(byte[])
How do I convert the listInt to bytes.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to convert each integer value to 4 bytes, forming an array of bytes that is
4*listInt.size()bytes long.One way to do this is to make use of NIO’s ByteBuffer class:
Note that there are two common ways of converting an array of integers to an array of bytes. The difference, however, is simply the choice of Endianness. Some people choose to calculate the Big Endian byte representation of integers; others choose to calculate the little Endian representation of integers. It doesn’t matter which method you pick as long as you calculate the byte representation of each integer consistently.