Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int count = 0;
- long a = 0L;
- long b = 0L;
- long overflow = 0L;
- long max = 4294967296L;
- long c = 0;
- if (str.length() != 7) {
- System.out.println("- Failed clientcode proof length test: " + str + " -> length: " + str.length());
- return false;
- }
- while (count < str.length() -1) {
- a = c << 4;
- b = str.getBytes()[count];
- c = a ^ b;
- overflow = c >> 32;
- c = c & 0xFFFFFFFF;
- c = c ^ overflow;
- System.out.printf( "a=%15d %45sn", a, Long.toBinaryString( a ));
- System.out.printf( "b=%15d %45sn", b, Long.toBinaryString( b ));
- System.out.printf( "c=%15d %45sn", c, Long.toBinaryString( c ));
- System.out.println( "---------------------------------------------------------------");
- count++;
- }
- if (c > 2147483647) {
- c = c - max;
- } else if (c >= 32768 && c <= 65535) {
- c = c - 65536;
- } else if (c >= 128 && c <= 255) {
- c = c - 256;
- }
- String strTekenreeks = "BCDFGHJKMNPQRSTWXYZ23456789";
- // Java result
- // int intModulus = toIntExact(c) % 27;
- int intModulus = (int)c % 27;
- String strCalculatedChar = strTekenreeks.substring(intModulus, intModulus + 1);
- System.out.printf("Java checksum : %s, modulo %d=%d, %s, %sn", c, 27, toIntExact(c) % 27, strTekenreeks, strCalculatedChar);
- // T-SQl result
- intModulus = 158510959 % 27;
- strCalculatedChar = strTekenreeks.substring(intModulus, intModulus + 1);
- System.out.printf("T-SQL checksum : %s, modulo %d=%d, %s, %sn", "158510959", 27, toIntExact(158510959) % 27, strTekenreeks, strCalculatedChar);
- //
- String strLastChar = str.substring(6, 7);
- if (strLastChar.equals(strCalculatedChar)) {
- System.out.println("- Passed clientcode proof");
- return true;
- } else {
- System.out.println("- Failed clientcode proof: " + str + ", calculated character: " + strCalculatedChar);
- return false;
- // return true;
- }
- File: S5WKBCK_testcodeS5WKBCK.pdf
- a= 0 0
- b= 83 1010011
- c= 83 1010011
- ---------------------------------------------------------------
- a= 1328 10100110000
- b= 53 110101
- c= 1285 10100000101
- ---------------------------------------------------------------
- a= 20560 101000001010000
- b= 87 1010111
- c= 20487 101000000000111
- ---------------------------------------------------------------
- a= 327792 1010000000001110000
- b= 75 1001011
- c= 327739 1010000000000111011
- ---------------------------------------------------------------
- a= 5243824 10100000000001110110000
- b= 66 1000010
- c= 5243890 10100000000001111110010
- ---------------------------------------------------------------
- a= 83902240 101000000000011111100100000
- b= 67 1000011
- c= 83902307 101000000000011111101100011
- ---------------------------------------------------------------
- Java binary_checksum() : 83902307, modulo 27=23, BCDFGHJKMNPQRSTWXYZ23456789, 6
- - Failed proof: S5WKBCK, calculated character: 6
- T-SQL binary_checksum() : 158510959, modulo 27=7, BCDFGHJKMNPQRSTWXYZ23456789, K
- - Passed proof: S5WKBCK, calculated character: K
Add Comment
Please, Sign In to add comment