@Test public void testConvertToSixteenBits() throws Exception { int num = checksumCalculator.convertToSixteenBits("16cdd"); assertThat(num, is(27870)); }
public static int convertToSixteenBits(String strToConvert) { StringBuilder sb = new StringBuilder(strToConvert); sb = sb.reverse(); StringBuilder s1 = new StringBuilder(sb.substring(0, 4)); s1 = s1.reverse(); StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length())); s2 = s2.reverse(); int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16); return num; }
ChecksumCalculator { public static int convertToSixteenBits(String strToConvert) { StringBuilder sb = new StringBuilder(strToConvert); sb = sb.reverse(); StringBuilder s1 = new StringBuilder(sb.substring(0, 4)); s1 = s1.reverse(); StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length())); s2 = s2.reverse(); int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16); return num; } }
ChecksumCalculator { public static int convertToSixteenBits(String strToConvert) { StringBuilder sb = new StringBuilder(strToConvert); sb = sb.reverse(); StringBuilder s1 = new StringBuilder(sb.substring(0, 4)); s1 = s1.reverse(); StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length())); s2 = s2.reverse(); int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16); return num; }  }
ChecksumCalculator { public static int convertToSixteenBits(String strToConvert) { StringBuilder sb = new StringBuilder(strToConvert); sb = sb.reverse(); StringBuilder s1 = new StringBuilder(sb.substring(0, 4)); s1 = s1.reverse(); StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length())); s2 = s2.reverse(); int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16); return num; }  static int convertToSixteenBits(String strToConvert); boolean isValidOspfCheckSum(OspfMessage ospfMessage, int checksumPos1, int checksumPos2); boolean isValidLsaCheckSum(OspfLsa ospfLsa, int lsType, int lsaChecksumPos1,
                                      int lsaChecksumPos2); boolean validateLsaCheckSum(byte[] lsaPacket, int lsaChecksumPos1, int lsaChecksumPos2); boolean validateOspfCheckSum(byte[] ospfPacket, int checksumPos1, int checksumPos2); byte[] calculateLsaChecksum(byte[] lsaBytes, int lsaChecksumPos1, int lsaChecksumPos2); byte[] calculateOspfCheckSum(byte[] packet, int checksumPos1, int checksumPos2); }
ChecksumCalculator { public static int convertToSixteenBits(String strToConvert) { StringBuilder sb = new StringBuilder(strToConvert); sb = sb.reverse(); StringBuilder s1 = new StringBuilder(sb.substring(0, 4)); s1 = s1.reverse(); StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length())); s2 = s2.reverse(); int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16); return num; }  static int convertToSixteenBits(String strToConvert); boolean isValidOspfCheckSum(OspfMessage ospfMessage, int checksumPos1, int checksumPos2); boolean isValidLsaCheckSum(OspfLsa ospfLsa, int lsType, int lsaChecksumPos1,
                                      int lsaChecksumPos2); boolean validateLsaCheckSum(byte[] lsaPacket, int lsaChecksumPos1, int lsaChecksumPos2); boolean validateOspfCheckSum(byte[] ospfPacket, int checksumPos1, int checksumPos2); byte[] calculateLsaChecksum(byte[] lsaBytes, int lsaChecksumPos1, int lsaChecksumPos2); byte[] calculateOspfCheckSum(byte[] packet, int checksumPos1, int checksumPos2);  }