示例#1
0
 /**
  * Decodes a URL safe string into its original form. Escaped characters are converted back to
  * their original representation.
  *
  * @param pString URL safe string to convert into its original form
  * @return original string
  * @throws RuntimeException Thrown if URL decoding is unsuccessful. This only happens in the case
  *     of a UnsupportedEncodingException which should never occur in reality.
  */
 public static String decodeURL(String url) {
   try {
     return urlCodec.decode(url);
   } catch (DecoderException exp) {
     //            NLogger.error( URLCodecUtils.class, exp, exp );
     throw new RuntimeException(exp.toString() + ": " + exp.getMessage());
   }
 }
示例#2
0
 public static byte[] hexDecode(String s) {
   try {
     return Hex.decodeHex(s.toCharArray());
   } catch (DecoderException e) {
     throw new ClientProblemException(
         "Hex content is not valid hex: " + e.getMessage() + ": " + s);
   }
 }
示例#3
0
  @Test
  public void scryptRuby() {
    int N = 1024;
    int r = 8;
    int p = 1;

    String hashed = SCryptUtil.scryptRuby(passwd, N, r, p);
    String[] parts = hashed.split("\\$");

    assertEquals(5, parts.length);
    try {
      assertEquals(8, Hex.decodeHex(parts[3].toCharArray()).length);
      assertEquals(32, Hex.decodeHex(parts[4].toCharArray()).length);
    } catch (DecoderException e) {
      fail("There was an exception decoding the hashed value: \n" + e.getMessage());
    }
    assertEquals(N, Integer.parseInt(parts[0], 16));
    assertEquals(r, Integer.parseInt(parts[1], 16));
    assertEquals(p, Integer.parseInt(parts[2], 16));
  }