RPC-GWT Serialization/java.util.Date Encoding -


i'm creating script serializes gwt requests , have problem encoding date values comply rpc-gwt standard. going through http logs noticed date values converted strings of 7 characters can't recognize algorithm used patterns.

does know algorithm used encrypt date values?

those date values serialized long values => milliseconds since epoch (january 1 1970) , serialized in packed form base64 become shorter strings. here have look:

/**    * parse string containing base-64 encoded version of long value.    *    * keep synchronized version in base64utils.    */   static long longfrombase64(string value) {     int pos = 0;     long longval = base64value(value.charat(pos++));     int len = value.length();     while (pos < len) {       longval <<= 6;       longval |= base64value(value.charat(pos++));     }     return longval;   }   /**    * return optionally single-quoted string containing base-64 encoded    * version of given long value.    *    * keep synchronized version in base64utils.    */   static string longtobase64(long value) {     // convert ints avoid need long ops     int low = (int) (value & 0xffffffff);     int high = (int) (value >> 32);     stringbuilder sb = new stringbuilder();     boolean havenonzero = base64append(sb, (high >> 28) & 0xf, false);     havenonzero = base64append(sb, (high >> 22) & 0x3f, havenonzero);     havenonzero = base64append(sb, (high >> 16) & 0x3f, havenonzero);     havenonzero = base64append(sb, (high >> 10) & 0x3f, havenonzero);     havenonzero = base64append(sb, (high >> 4) & 0x3f, havenonzero);     int v = ((high & 0xf) << 2) | ((low >> 30) & 0x3);     havenonzero = base64append(sb, v, havenonzero);     havenonzero = base64append(sb, (low >> 24) & 0x3f, havenonzero);     havenonzero = base64append(sb, (low >> 18) & 0x3f, havenonzero);     havenonzero = base64append(sb, (low >> 12) & 0x3f, havenonzero);     base64append(sb, (low >> 6) & 0x3f, havenonzero);     base64append(sb, low & 0x3f, true);     return sb.tostring();   }   private static boolean base64append(stringbuilder sb, int digit, boolean havenonzero) {     if (digit > 0) {       havenonzero = true;     }     if (havenonzero) {       int c;       if (digit < 26) {         c = 'a' + digit;       } else if (digit < 52) {         c = 'a' + digit - 26;       } else if (digit < 62) {         c = '0' + digit - 52;       } else if (digit == 62) {         c = '$';       } else {         c = '_';       }       sb.append((char) c);     }     return havenonzero;   }   // assume digit 1 of [a-za-z0-9$_]   private static int base64value(char digit) {     if (digit >= 'a' && digit <= 'z') {       return digit - 'a';     }     // no need check digit <= 'z'     if (digit >= 'a') {       return digit - 'a' + 26;     }     if (digit >= '0' && digit <= '9') {       return digit - '0' + 52;     }     if (digit == '$') {       return 62;     }     // digit == '_'     return 63;   } 

i did myself in php guidance of colin alworth


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -