JAVA做一个简单的MD5加密...
来源:百度知道 编辑:UC知道 时间:2024/09/20 21:56:03
老师出的题```
让用户输入一个小于8位的整数 首先要把这些数倒序 每个数加5 加5的结果再对10取模 之后再把第一个数和最后一个数换位 输出
不用麻烦的
就利用数组
还有Scanner的包
最后输出看结果是啥
高手赐教啊
自己弄出来了
说了哦 不要其他的 我都还没学到呢
让用户输入一个小于8位的整数 首先要把这些数倒序 每个数加5 加5的结果再对10取模 之后再把第一个数和最后一个数换位 输出
不用麻烦的
就利用数组
还有Scanner的包
最后输出看结果是啥
高手赐教啊
自己弄出来了
说了哦 不要其他的 我都还没学到呢
常用的MD5加密类
package org.tool;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5_Encoding
{
private MessageDigest md = null;
private static MD5_Encoding md5 = null;
private static final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/**
* Constructor is private so you must use the getInstance method
*/
private MD5_Encoding() throws NoSuchAlgorithmException
{
md = MessageDigest.getInstance("MD5");
}
/**
* This returns the singleton instance
*/
public static MD5_Encoding getInstance() throws NoSuchAlgorithmException
{
if (md5 == null)
{