Mercurial Hosting > luan
diff src/goodjava/util/GoodUtils.java @ 1583:1cc6c7fa803d
mail work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 07 Mar 2021 02:22:09 -0700 |
parents | |
children | 2f4c99c02436 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/goodjava/util/GoodUtils.java Sun Mar 07 02:22:09 2021 -0700 @@ -0,0 +1,20 @@ +package goodjava.util; + +import java.io.UnsupportedEncodingException; +import java.util.Base64; + + +public final class GoodUtils { + + public static byte[] getBytes(String s,String charsetName) { + try { + return s.getBytes(charsetName); + } catch(UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + public static String base64Encode(String s) { + return Base64.getEncoder().encodeToString(getBytes(s,"UTF-8")); + } +}