How to Generate Adler32 Checksum in Java


In this example, we will learn how to get the Adler32 checksum value for an array of bytes using Adler32 Java class.

Source Code

package com.beginner.examples;

import java.util.zip.Adler32;
import java.util.zip.Checksum;
 
public class Adler32Example {
	
	public static void main(String args[]){
		
		String str = "string example";
		
		//Convert string to bytes
		byte bytes[] = str.getBytes();
		
		Checksum adler32 = new Adler32();
		 
		adler32.update(bytes,0,bytes.length);
		//get adler32 check number
		long checknum = adler32.getValue();
		
		System.out.println("Adler32 checknum is : " + checknum);
	}
 
}

Output:

Adler32 checknum is : 716899748

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments