MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / crcHeader

Method crcHeader

java/src/cx/fbn/encrypt/EnCrypt.java:323–336  ·  view source on GitHub ↗
(byte[] bytes)

Source from the content-addressed store, hash-verified

321 // Utility function to return the CRC header of an encoded string. This is
322 // used to verify good decryption and put in front of a new encrypted string
323 private String crcHeader(byte[] bytes) {
324 CRC32 crc = new CRC32();
325 crc.update(bytes);
326 int realCRC = (int)crc.getValue();
327
328 // The first 4 chars of the hex string will equal the first
329 // 4 chars of the decyphered text. If they match we have a
330 // good password. This is what we return
331 realCRC = realCRC ^ (-1);
332 realCRC = realCRC >>> 0;
333 String hexCRC = Integer.toHexString(realCRC).substring(0,4);
334 return hexCRC.toString().toUpperCase();
335
336 }
337
338}

Callers 2

encodeStringMethod · 0.95
decodeBytesMethod · 0.95

Calls 2

updateMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected