- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the Checksum of a Byte Array in Java?
Create a Byte Array for which you want the Checksum −
byte[] arr = "This is it!".getBytes();
Now, create a Checksum object −
Checksum checksum = new Adler32(); checksum.update(arr, 0, arr.length);
The update() above updates the current checksum with the specified array of bytes.
Now, get the checksum with getValue() method, which gives the current checksum value.
Example
import java.util.zip.Adler32; import java.util.zip.Checksum; public class Demo { public static void main(String[] argv) throws Exception { byte[] arr = "This is it!".getBytes(); Checksum checksum = new Adler32(); checksum.update(arr, 0, arr.length); long res = checksum.getValue(); System.out.println("Checksum of a Byte array = "+res); } }
Output
Checksum of a Byte array = 391709619
- Related Articles
- Get byte array from BigInteger in Java
- How to print a byte array in Java?
- How to concatenate byte array in java?
- How to convert a PDF to byte array in Java?
- How to write contents of a file to byte array in Java?
- How to convert BLOB to Byte Array in java?
- How to convert Byte Array to Image in java?
- How to convert Image to Byte Array in java?
- How to convert InputStream to byte array in Java?
- How to convert a byte array to hex string in Java?
- How to convert a byte array to a hex string in Java?
- How to overwrite a specific chunk in a byte array using java?
- How to convert an object to byte array in java?
- How to convert java bitmap to byte array In android?
- How to convert hex string to byte Array in Java?

Advertisements