Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package purejava;
import java.util.Base64;
public class Base64Smaple {
public static void main(String[] args) {
String in = "d!\"#$%&'()=~|";
var encodeData = Base64.getEncoder().encode(in.getBytes()); // エンコード
System.out.println(new String(encodeData)); // ZCEiIyQlJicoKT1+fA== プラスが含まれている
var decodeData1 = new String(Base64.getUrlDecoder().decode(encodeData)); // 正常にデコードできない為、エラーとなる
// java.lang.IllegalArgumentException: Illegal base64 character 2b
System.out.println(decodeData1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment