Calculates a CRC-32 checksum for the given bytes. - Java Security

Java examples for Security:CRC

Description

Calculates a CRC-32 checksum for the given bytes.

Demo Code


//package com.java2s;

import java.util.zip.CRC32;

public class Main {
    /**/* w ww .  ja v  a 2 s. c  o  m*/
     * Calculates a CRC-32 checksum for the given bytes.
     * 
     * @param bytes
     *            the bytes.
     * @return a checksum.
     */
    public static long calculateChecksum(byte[] bytes) {
        CRC32 crc = new CRC32();
        crc.update(bytes);
        return crc.getValue();
    }
}

Related Tutorials