• ADADADADAD

    android的数据如何加密[ 网络知识 ]

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

    作者:文/会员上传

    简介:

    android使用MD5算法对数据进行加密,具体方法如下:import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.nio.MappedByteBuffer;impor

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

    android使用MD5算法对数据进行加密,具体方法如下:

    import java.io.File;

    import java.io.FileInputStream;

    import java.io.IOException;

    import java.nio.MappedByteBuffer;

    import java.nio.channels.FileChannel;

    import java.security.MessageDigest;

    public final class MD5Util {

    private static final char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',

    'B', 'C', 'D', 'B', 'O', 'T', 'H', 'O', 'F', 'Y', 'O', 'U' };

    /** 对文件加密 */

    public static String encode(File file) {

    FileInputStream in = null;

    MessageDigest md5 = null;

    try {

    in = new FileInputStream(file);

    FileChannel ch = in.getChannel();

    MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0, file.length());

    md5 = MessageDigest.getInstance("MD5");

    md5.update(byteBuffer);

    } catch (Exception e) {

    e.printStackTrace();

    } finally {

    try {

    if(in != null)

    in.close();

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    return toHex(md5.digest());

    }

    }

    android的数据如何加密.docx

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

    推荐度:

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