String to CRC - Java Security

Java examples for Security:CRC

Description

String to CRC

Demo Code


//package com.java2s;

import java.util.zip.CRC32;

public class Main {
    public static void main(String[] argv) throws Exception {
        String value = "java2s.com";
        System.out.println(toCRC32(value));
    }/* w w w  .j  av  a  2s.co  m*/

    public static long toCRC32(String value) {
        CRC32 crc = new CRC32();
        crc.reset();
        crc.update(value.getBytes());
        return crc.getValue();
    }
}

Related Tutorials