Java CRC32 Byte Array crc32Number(String s)

Here you can find the source of crc32Number(String s)

Description

crc Number

License

Apache License

Declaration

public static long crc32Number(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.zip.CRC32;
import java.util.zip.Checksum;

public class Main {
    public static long crc32Number(String s) {
        try {// www  .ja v  a 2 s  . co  m
            // Convert string to bytes
            byte bytes[] = s.getBytes();
            Checksum checksum = new CRC32();
            checksum.update(bytes, 0, bytes.length);

            /*
             * Get the generated checksum using getValue method of CRC32 class.
             */
            long lngChecksum = checksum.getValue();
            return lngChecksum;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}

Related

  1. CRC32(byte[] buffer)
  2. crc32(byte[] bytes)
  3. crc32(byte[] bytes)
  4. crc32(final byte[] bytes)
  5. crc32(String value)
  6. crcBytes(byte[]... data)
  7. createRandomCrc32Hex()
  8. getCRC()
  9. getCrc32(byte[] buf)