Java examples for Security:CRC
create Crc Hex
//package com.java2s; import java.util.zip.CRC32; import java.util.zip.Checksum; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(createCrc32Hex(value)); }/*from w ww . j av a 2 s . c om*/ public static String createCrc32Hex(String value) { byte bytes[] = value.getBytes(); Checksum checksumCreator = new CRC32(); checksumCreator.update(bytes, 0, bytes.length); long checkSumValue = checksumCreator.getValue(); return fixLength(Long.toHexString(checkSumValue)); } private static String fixLength(String hexString) { while (hexString.length() != 8) { hexString = "0" + hexString; } return hexString; } }