md5digesttest.java.svn-base

来自「项目支付宝批量打款,采用httpclient+spring +quarz实现.」· SVN-BASE 代码 · 共 52 行

SVN-BASE
52
字号
/**
 * Alipay.com Inc.
 * Copyright (c) 2005-2007 All Rights Reserved.
 */
package com.alipay.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.IOUtils;
import org.junit.Test;


/**
 * 
 * 批量代发-上传付款文件测试
 *
 * @author en.xuze
 *
 * @version $Id$
 */
public class Md5DigestTest {

    @Test
    public void md5Test() throws IOException {

        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream(new File("c:\\20080128_001.csv"));
            int size = fileInputStream.available();
            byte[] content = new byte[size];
            //md5方式*********************************************************************
            DigestUtils.md5(content);                  
            //需要使用IOUtils.toByteArray是否提醒商户知道?
            System.out.println(DigestUtils.md5Hex(IOUtils.toByteArray(fileInputStream)));
            
	   /*sha方式 ******************************************************
            DigestUtils.shaHex(IOUtils.toByteArray(fileInputStream));
                       DigestUtils.sha(content);
                       System.out.println(DigestUtils.shaHex(content)); */
       //***************************************************************              
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            fileInputStream.close();

        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?