GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Others/crc32.java at master · rpendrick/Java Expand file tree/ Copy pathcrc32.javaMore file actions 27 lines (22 loc) · 902 Bytes / Copy pathcrc32.javaFile metadata and controls27 lines (22 loc) · 902 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import java.util.BitSet; //Generates a crc32 checksum for a given string or byte array public class crc32 { public static void main(String[] args) { System.out.println(Integer.toHexString(crc32("Hello World"))); } public static int crc32(String str) { return crc32(str.getBytes()); } public static int crc32(byte[] data) { BitSet bitSet = BitSet.valueOf(data); int crc32 = 0xFFFFFFFF; //initial value for(int i=0;i<data.length*8;i++) { if(((crc32>>>31)&1) != (bitSet.get(i)?1:0)) crc32 = (crc32 << 1) ^ 0x04C11DB7; //xoring with polynomial else crc32 = (crc32 << 1); } crc32 = Integer.reverse(crc32); //result reflect return crc32 ^ 0xFFFFFFFF; //final xor value } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |