Base64加密和解密
Base64URLSafeString
1 /** 2 * 将内容进行Base64加密 3 * 4 * @param content 5 * @return 6 * @throws UnsupportedEncodingException 7 */ 8 public static String Base64encodeBase64URLSafeString(String content) throws Exception { 9 String base64Str = ""; 10 try { 11 base64Str = Base64.encodeBase64URLSafeString(content.getBytes("UTF-8")); 12 } catch (Exception e) { 13 System.out.println(e.getMessage()); 14 } 15 return base64Str; 16 }
BASE64加密
1 /** 2 * 普通Base64加密 3 * 4 * @param str 5 * @return 6 * @throws IOException 7 */ 8 public static String BASE64Encoder(String str) throws IOException { 9 BASE64Encoder encoder = new BASE64Encoder(); 10 String encode = encoder.encode(str.getBytes("UTF-8"));//编码 11 return encode; 12 }
BASE64解密
1 /** 2 * 普通Base64解密 3 * 4 * @param str 5 * @return 6 * @throws IOException 7 */ 8 public static String BASE64Decoder(String str) throws IOException { 9 BASE64Decoder decoder = new BASE64Decoder(); 10 String decode = new String(decoder.decodeBuffer(str), "UTF-8"); 11 return decode; 12 }
原创文章,转载请说明出处,谢谢合作
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律