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. String chanlCustNo = "SZ32200009024371101";
  14. int len = 32 - date.length() - chanlCustNo.length();
  15. StringBuilder sb = new StringBuilder();
  16. for(int i = 0; i < len; i++) {
  17. sb.append( "0");
  18. }
  19. String key = sb.toString() + chanlCustNo + date;
  20. key = key.substring(0, 32);
  21. System.out.println(key);
  22.  
  23.  
  24. String text = key;
  25. byte[] hexbyte = text.getBytes();
  26. System.out.println(hexbyte);
  27. byte[] bitmap = new byte[hexbyte.length / 2];
  28. for (int i = 0; i < bitmap.length; i++) {
  29. hexbyte[i * 2] -= hexbyte[i * 2] > '9' ? 7 : 0;
  30. hexbyte[i * 2 + 1] -= hexbyte[i * 2 + 1] > '9' ? 7 : 0;
  31. bitmap[i] = (byte) ((hexbyte[i * 2] << 4 & 0xf0) | (hexbyte[i * 2 + 1] & 0x0f));
  32. }
  33. System.out.println(bitmap);
  34. }
  35. }
Success #stdin #stdout 0.21s 59048KB
stdin
Standard input is empty
stdout
0000000SZ32200009024371101251022
[B@7699a589
[B@58372a00