简易的Base64加密工具开发步骤
1、编写Java测试桩
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import sun.misc.BASE64Encoder; public class Base64Encryption { public static void main(String[] args) throws IOException { BufferedReader reader = null; while (true) { System.out.println("请输入密码:"); reader = new BufferedReader(new InputStreamReader(System.in)); String input = reader.readLine(); if (null == input || "".equals(input)) { System.out.println("密码不能为空! 请重新输入"); continue; } String output = new BASE64Encoder().encodeBuffer(input.getBytes()); System.out.println(output); break; } } }
2、使用bat命令调用Java测试桩【encrypt.bat】
@javac Base64Encryption.java
@java Base64Encryption
@pause
ps:Base64Encryption.java和bat命令文件放置同一个文件夹
3、测试
双击encrpt.bat,按提示输入密码,测试结果如下:
PS: