@Override public String encode(byte[] bytes) { return new Base32().encodeToString(bytes); } }
@Override public String encode(byte[] bytes) { return new Base32().encodeToString(bytes); } }
/** * This method calculates the secret key given a random byte buffer. * * @param secretKey a random byte buffer. * @return the secret key. */ private String calculateSecretKey(byte[] secretKey) { switch (config.getKeyRepresentation()) { case BASE32: return new Base32().encodeToString(secretKey); case BASE64: return new Base64().encodeToString(secretKey); default: throw new IllegalArgumentException("Unknown key representation type."); } }
/** * Base32-encode the given byte[] as a string. * * @param data the byte array to encode * @param chunked the chunked * @return the encoded string */ public static String encodeBase32(final byte[] data, final boolean chunked) { if (chunked) { return BASE32_CHUNKED_ENCODER.encodeToString(data).trim(); } return BASE32_UNCHUNKED_ENCODER.encodeToString(data).trim(); }
@Override public String encode(byte[] bytes) { return new Base32().encodeToString(bytes); } }
@Override public String encode(byte[] bytes) { return new Base32().encodeToString(bytes); } }
public String toString() { return (new Base32()).encodeToString(this.secret); }
/** * This method calculates the secret key given a random byte buffer. * * @param secretKey a random byte buffer. * @return the secret key. */ private String calculateSecretKey(byte[] secretKey) { switch (config.getKeyRepresentation()) { case BASE32: return new Base32().encodeToString(secretKey); case BASE64: return new Base64().encodeToString(secretKey); default: throw new IllegalArgumentException("Unknown key representation type."); } }
/** * Get its value for cookie. * @return The value */ public String cookie() { final ByteArrayOutputStream data = new ByteArrayOutputStream(); final DataOutputStream stream = new DataOutputStream(data); try { stream.writeUTF(this.urn().toString()); stream.writeUTF(this.name()); stream.writeUTF(this.photo().toString()); } catch (final IOException ex) { throw new IllegalArgumentException(ex); } finally { IOUtils.closeQuietly(stream); } return StringUtils.join( Encrypted.CODER.encodeToString( Encrypted.xor( Encrypted.salt(data.toByteArray()), this.key.getBytes(Charsets.UTF_8) ) ).split("(?<=\\G.{8})"), "-" ); }