List of usage examples for org.apache.wicket.util.crypt Base64 Base64
public Base64(int lineLength, byte[] lineSeparator, final boolean urlSafe)
From source file:sf.wicklet.ext.application.DefaultWickletCrypt.java
License:Apache License
@Override public final String encryptUrlSafe(final String text) { String s = Lazy.salt16 + text; s += TextUtil.toLowerHex8(s.hashCode()); try {/* w w w. j ava 2s .c o m*/ final byte[] encrypted = Lazy.crypt.crypt(salte(Lazy.salt, s.getBytes(CHARACTER_ENCODING)), Cipher.ENCRYPT_MODE); if (encrypted != null) { return PREFIX + new String(new Base64(-1, null, true).encode(encrypted), CHARACTER_ENCODING); } } catch (final GeneralSecurityException e) { log.error("Unable to encrypt text '" + text + "'", e); } catch (final UnsupportedEncodingException e) { log.error("Unable to encrypt text '" + text + "'", e); } return null; }