fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.text.SimpleDateFormat;
  7. import java.util.Date;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Main {
  11. public static void main(String[] args) {
  12. String date = new SimpleDateFormat("yyMMdd").format( new Date());
  13.  
  14. String chanlCustNo = "SZ32200009024371101";
  15. int len = 32 - date.length() - chanlCustNo.length();
  16. StringBuilder sb = new StringBuilder();
  17. for(int i = 0; i < len; i++) {
  18. sb.append( "0");
  19. }
  20. String key = sb.toString() + chanlCustNo + date;
  21. key = key.substring(0, 32);
  22. System.out.println(key);
  23.  
  24.  
  25. String text = key;
  26. byte[] hexbyte = text.getBytes();
  27. // for (byte b : hexbyte) {
  28. // System.out.println(b);
  29. // };
  30. System.out.println("------------");
  31.  
  32. byte[] bitmap = new byte[hexbyte.length / 2];
  33. for (int i = 0; i < bitmap.length; i++) {
  34. System.out.println(hexbyte[i * 2]);
  35. System.out.println(hexbyte[i * 2 + 1]);
  36. System.out.println("------------1");
  37.  
  38. hexbyte[i * 2] -= hexbyte[i * 2] > '9' ? 7 : 0;
  39. hexbyte[i * 2 + 1] -= hexbyte[i * 2 + 1] > '9' ? 7 : 0;
  40. System.out.println(hexbyte[i * 2]+ "hexbyte[i * 2]");
  41. System.out.println(hexbyte[i * 2 + 1]+"hexbyte[i * 2 + 1]");
  42. bitmap[i] = (byte) ((hexbyte[i * 2] << 4 & 0xf0) | (hexbyte[i * 2 + 1] & 0x0f));
  43. System.out.println(bitmap[i]+ "bitmap[i]");
  44. System.out.println("------------3");
  45. }
  46. for (byte b : bitmap) {
  47. System.out.println(b);
  48. };
  49. System.out.println(bitmap);
  50. }
  51. }
Success #stdin #stdout 0.26s 59108KB
stdin
Standard input is empty
stdout
0000000SZ32200009024371101251022
------------
48
48
------------1
48hexbyte[i * 2]
48hexbyte[i * 2 + 1]
0bitmap[i]
------------3
48
48
------------1
48hexbyte[i * 2]
48hexbyte[i * 2 + 1]
0bitmap[i]
------------3
48
48
------------1
48hexbyte[i * 2]
48hexbyte[i * 2 + 1]
0bitmap[i]
------------3
48
83
------------1
48hexbyte[i * 2]
76hexbyte[i * 2 + 1]
12bitmap[i]
------------3
90
51
------------1
83hexbyte[i * 2]
51hexbyte[i * 2 + 1]
51bitmap[i]
------------3
50
50
------------1
50hexbyte[i * 2]
50hexbyte[i * 2 + 1]
34bitmap[i]
------------3
48
48
------------1
48hexbyte[i * 2]
48hexbyte[i * 2 + 1]
0bitmap[i]
------------3
48
48
------------1
48hexbyte[i * 2]
48hexbyte[i * 2 + 1]
0bitmap[i]
------------3
57
48
------------1
57hexbyte[i * 2]
48hexbyte[i * 2 + 1]
-112bitmap[i]
------------3
50
52
------------1
50hexbyte[i * 2]
52hexbyte[i * 2 + 1]
36bitmap[i]
------------3
51
55
------------1
51hexbyte[i * 2]
55hexbyte[i * 2 + 1]
55bitmap[i]
------------3
49
49
------------1
49hexbyte[i * 2]
49hexbyte[i * 2 + 1]
17bitmap[i]
------------3
48
49
------------1
48hexbyte[i * 2]
49hexbyte[i * 2 + 1]
1bitmap[i]
------------3
50
53
------------1
50hexbyte[i * 2]
53hexbyte[i * 2 + 1]
37bitmap[i]
------------3
49
48
------------1
49hexbyte[i * 2]
48hexbyte[i * 2 + 1]
16bitmap[i]
------------3
50
50
------------1
50hexbyte[i * 2]
50hexbyte[i * 2 + 1]
34bitmap[i]
------------3
0
0
0
12
51
34
0
0
-112
36
55
17
1
37
16
34
[B@7ef20235