Beispiel #1
0
 /** ** Scrambles String */
 public static String _ens64(String d) {
   if (!StringTools.isBlank(d)) {
     return Base64.encode(StringTools.getBytes(d), getBase64Alphabet(), Base64Pad);
   } else {
     return "";
   }
 }
Beispiel #2
0
 /** ** Descrambles String */
 public static String _des64(String e) {
   if (!StringTools.isBlank(e)) {
     byte b[] = Base64.decode(e, getBase64Alphabet(), Base64Pad);
     return StringTools.toStringValue(b, ' ');
   } else {
     return "";
   }
 }
Beispiel #3
0
 /** ** Descrambles String */
 public static String _des64(String e) {
   if (!StringTools.isBlank(e)) {
     try {
       byte b[] = Base64.decode(e, getBase64Alphabet(), Base64Pad);
       return StringTools.toStringValue(b, ' ');
     } catch (Base64.Base64DecodeException bde) {
       Print.logError("Invalid Base64 characters", bde);
       return "";
     }
   } else {
     return "";
   }
 }
Beispiel #4
0
 /** ** Gets the scrambled Base64 alphabet ** @return The scrambled Base64 alphabet */
 private static char[] getBase64Alphabet() {
   if (Base64Alphabet == null) {
     BigInteger seed = RTConfig.getBigInteger(PROP_uriArgScrambleSeed, DefaultScrambleSeed);
     Base64Alphabet = Base64.shuffleAlphabet(seed);
     for (int i = 0; i < Base64Alphabet.length; i++) {
       if (Base64Alphabet[i] == '+') {
         Base64Alphabet[i] = '-';
       } else if (Base64Alphabet[i] == '/') {
         Base64Alphabet[i] = '_';
       }
     }
     // Print.logInfo("Base64 Alpha ["+seed+"]: "+StringTools.toStringValue(Base64Alphabet));
   }
   return Base64Alphabet;
 };