protected static String encodePart(String part) { return Codec.encodeUrlSafeBase64(part); } protected static String encodePart(byte[] part) {
protected static String encodePart(byte[] part) { return Codec.encodeUrlSafeBase64(part); }
protected static String encodePart(String part) { return Codec.encodeUrlSafeBase64(part); } protected static String encodePart(byte[] part) {
protected static String encodePart(byte[] part) { return Codec.encodeUrlSafeBase64(part); }
/** * Generate a secret string from random byte array * @param len the number of bytes used to generate the secret * @return the secret */ public static String genSecret(int len) { SecureRandom random = new SecureRandom(); byte[] bytes = new byte[len]; random.nextBytes(bytes); String s = Codec.encodeUrlSafeBase64(bytes); if (s.endsWith(".")) { s = S.beforeFirst(s, "."); } return s; }
/** * Generate a secret string from random byte array * @param len the number of bytes used to generate the secret * @return the secret */ public static String genSecret(int len) { SecureRandom random = new SecureRandom(); byte[] bytes = new byte[len]; random.nextBytes(bytes); String s = Codec.encodeUrlSafeBase64(bytes); if (s.endsWith(".")) { s = S.beforeFirst(s, "."); } return s; }