永发信息网

一段JAVA看不懂

答案:2  悬赏:50  手机版
解决时间 2021-04-06 20:04
  • 提问者网友:伴风望海
  • 2021-04-06 15:39
public static String MD5(String paramString)
{
byte[] arrayOfByte;
StringBuffer localStringBuffer;
int i;
try
{
MessageDigest localMessageDigest = MessageDigest.getInstance("MD5");
localMessageDigest.reset();
localMessageDigest.update(paramString.getBytes("UTF-8"));
arrayOfByte = localMessageDigest.digest();
localStringBuffer = new StringBuffer();
i = 0;
if (i >= arrayOfByte.length)
{
str = localStringBuffer.toString().toLowerCase();
return str;
}
}
catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
{
while (true)
str = "";
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
while (true)
String str = "";
}
if (Integer.toHexString(0xFF & arrayOfByte[i]).length() == 1)
localStringBuffer.append("0").append(Integer.toHexString(0xFF & arrayOfByte[i]));
while (true)
{
i++;
break;
localStringBuffer.append(Integer.toHexString(0xFF & arrayOfByte[i]));
}
}

这是一段文本到md5的算法吗
具体怎么解释
最佳答案
  • 五星知识达人网友:痴妹与他
  • 2021-04-06 15:46
看着像是想使用MD5方法,但是本段代码逻辑混乱,有错误,肯定达不到想要的效果。
全部回答
  • 1楼网友:夜风逐马
  • 2021-04-06 16:40

public class dateclassdemo{

int year; //定义变量年

int month; //定义变量月

int day; //定义变量日

//下面是一个类似构造函数的方法,给变量赋值的

void setdate (int y, int m , int d) {

year=y;

month=m;

day=d;

}

//判断是否是闰年,闰年返回true,否则返回false

boolean isleapyear(int y){

//这个是判断闰年的公式,小时候学过

if(y%400==0||y%4==0&&y%100!=0)

return true;

else

return false;

}

//方法执行入口

public static void main(string args[]){

//创建对象

dateclassdemo d1; d1=new dateclassdemo();

给变量赋值

d1.setdate(2008,1,1);

//调用判断方法

if (d1.isleapyear(d1.year))

//如果是闰年输出d1.year +" is leap year!

system.out.println(d1.year +" is leap year!");

else

//如果不是闰年输出d1.year+" is not leap year!

system.out.println(d1.year+" is not leap year!");

}

}

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯