Base64加密工具-iBlogs

时间:2021-05-03 15:14:11

简易的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命令文件放置同一个文件夹

Base64加密工具-iBlogs

3、测试

双击encrpt.bat,按提示输入密码,测试结果如下:

Base64加密工具-iBlogs

PS:

[转] Java加密技术(一)——BASE64与单向加密算法MD5&SHA&MAC