Maddy.Shik Maddy.Shik - 1 month ago 13
Java Question

.net 3.5:how to implement calculate crc32 for data using dot net 3.5 api?

how to implement calculate crc32 for data using dot net 3.5 api.I have done the same in java with following code.

public static String getMAC (byte [] value) {
java.util.zip.CRC32 crc32 = new java.util.zip.CRC32 ();
crc32.update(value);
long newCRC = crc32.getValue();
String crcString = Long.toHexString(newCRC);
try {
crcString = ISOUtil.padleft(Long.toHexString(newCRC), 8, '0');
}
catch (Exception e){
e.printStackTrace();
}

if (ISOConstantsLibrary.DEBUG) System.out.println("for hex string: " + ISOUtil.hexString(value) + "\nmac" + crcString);
}

Answer

The .NET FCL doesn't provide a class like java.util.zip.CRC32 so you have to roll your own. It's not tough, there's some decent examples out there:

Example 1 Example 2

Comments