承接国内外服务器租用托管、定制开发、网站代运营、网站seo优化托管接单、网站代更新,新老站点皆可!!咨询QQ:3787320601
当前位置:首页  >  互联网圈  >  数据:jsp怎么把数据加密

数据:jsp怎么把数据加密

管理员 2023-03-31 09:36:58 互联网圈 42 ℃ 0 评论 1360字 收藏

jsp怎样把数据加密

jsp怎么把数据加密

jsp使用MD5对数据进行加密,具体方法以下:

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;


public class MD5Digest{

private MessageDigest __md5 = null;

private StringBuffer __digestBuffer = null;

public MD5Digest()


throws NoSuchAlgorithmException{

__md5 = MessageDigest.getInstance("MD5");

__digestBuffer = new StringBuffer();

}


public String md5crypt(String s){

__digestBuffer.setLength(0);

byte abyte0[] = __md5.digest(s.getBytes());

for(int i = 0; i < abyte0.length; i++)

__digestBuffer.append(toHex(abyte0[i]));

return __digestBuffer.toString();

}


public String toHex(byte one){

String HEX="0123456789ABCDEF";

char[] result=new char[2];

result[0]=HEX.charAt((one & 0xf0) >> 4);

result[1]=HEX.charAt(one & 0x0f);

String mm=new String(result);

return mm;

}

}



文章来源:丸子建站

文章标题:数据:jsp怎么把数据加密

https://www.wanzijz.com/view/5731.html

TAG: 数据加密 jsp
X

截屏,微信识别二维码

微信号:weimawl

(点击微信号复制,添加好友)

打开微信