• ADADADADAD

    jsp怎么把数据加密[ 网络知识 ]

    网络知识 时间:2024-12-03 10:20:15

    作者:文/会员上传

    简介:

    jsp使用MD5对数据进行加密,具体方法如下:import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;public class MD5Digest{private MessageDiges

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    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怎么把数据加密.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: 数据加密JSP