| | |
| | | package safeluck.drive.evaluation.util; |
| | | |
| | | import android.content.res.Resources; |
| | | import android.os.SystemClock; |
| | | import android.util.Log; |
| | | import android.util.TypedValue; |
| | | |
| | |
| | | return str.matches(regx); |
| | | } |
| | | |
| | | public static void main(String []args){ |
| | | String str = "EB00020000031420010000000400A5"; |
| | | // String str = "7EEB00020000031420010000000400A5007E"; |
| | | String str1 = "EB000200000314200100000004030D00"; |
| | | // String str1 = "7EEB000200000314200100000004030D00D57E"; |
| | | String str2 = "EB000200000314200100000004035000"; |
| | | byte [] dtas=BytesUtils.hexStringToBytes(str); |
| | | byte checkcode = calCheckCode(dtas); |
| | | System.out.println(BytesUtils.toHexString(checkcode)); |
| | | } |
| | | // public static void main(String []args){ |
| | | // String str = "EB00020000031420010000000400A5"; |
| | | //// String str = "7EEB00020000031420010000000400A5007E"; |
| | | // String str1 = "EB000200000314200100000004030D00"; |
| | | //// String str1 = "7EEB000200000314200100000004030D00D57E"; |
| | | // String str2 = "EB000200000314200100000004035000"; |
| | | // byte [] dtas=BytesUtils.hexStringToBytes(str); |
| | | // byte checkcode = calCheckCode(dtas); |
| | | // System.out.println(BytesUtils.toHexString(checkcode)); |
| | | // } |
| | | |
| | | |
| | | |
| | |
| | | return cipher.doFinal(src); |
| | | } |
| | | |
| | | public static int parseUnsignedInt(String s, int radix) |
| | | throws NumberFormatException { |
| | | if (s == null) { |
| | | throw new NumberFormatException("null"); |
| | | } |
| | | |
| | | int len = s.length(); |
| | | if (len > 0) { |
| | | char firstChar = s.charAt(0); |
| | | if (firstChar == '-') { |
| | | throw new |
| | | NumberFormatException(String.format("Illegal leading minus sign " + |
| | | "on unsigned string %s.", s)); |
| | | } else { |
| | | if (len <= 5 || // Integer.MAX_VALUE in Character.MAX_RADIX is 6 digits |
| | | (radix == 10 && len <= 9) ) { // Integer.MAX_VALUE in base 10 is 10 digits |
| | | return Integer.parseInt(s, radix); |
| | | } else { |
| | | long ell = Long.parseLong(s, radix); |
| | | if ((ell & 0xffff_ffff_0000_0000L) == 0) { |
| | | return (int) ell; |
| | | } else { |
| | | throw new |
| | | NumberFormatException(String.format("String value %s exceeds " + |
| | | "range of unsigned int.", s)); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | throw new NumberFormatException("For input string: \"" + s + "\""); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args){ |
| | | long longCurrTIme = System.currentTimeMillis()/1000; |
| | | long CurrTIme = System.currentTimeMillis(); |
| | | System.out.println("longCurrTIme="+longCurrTIme); |
| | | System.out.println("intCurrTIme="+CurrTIme); |
| | | int unsignedTime= parseUnsignedInt(String.valueOf(longCurrTIme),10); |
| | | System.out.println("unsigned int time = "+unsignedTime); |
| | | } |
| | | |
| | | } |