Java Base64 URL Safe Encoding
compile 'com.google.guava:guava:18.0'
Here is a simple example of encoding text with Base64 with Guava.
import com.google.common.io.BaseEncoding
import com.google.common.base.Preconditions
public class UrlSafeEncodingExample {
public static void main(String[] args) {
Preconditions.checkNotNull(args);
Preconditions.checkNotNull(args[0]);
String decodedString = args[0];
System.out.println("Decoded String: " + decodedString);
String encodedString = BaseEncoding.base64Url().encode(decodedString.getBytes('UTF-8'));
System.out.println("Encoded String: " + encodedString);
}
}
This comment has been removed by a blog administrator.
ReplyDelete