发表于: 2018-03-03 22:21:10

0 591


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

第三方支付API的调用与测试.


api提供的加密方法

package com.fuiou.pay.client.util;
import java.security.MessageDigest;

public class MD5 {
private final static String[] hexDigits = { "0", "1", "2", "3", "4", "5",
        "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };

  /**
   * 转换字节数组为16进制字串
   *
   * @param b
   *            字节数组
   * @return 16进制字串
   */
  public static String byteArrayToHexString(byte[] b) {
StringBuffer resultSb = new StringBuffer();
     for (int i = 0; i < b.length; i++) {
resultSb.append(byteToHexString(b[i]));
     }
return resultSb.toString();
  }

/**
   * J 转换byte16进制
   *
   * @param b
   * @return
   */
  private static String byteToHexString(byte b) {
int n = b;
     if (n < 0) {
n = 256 + n;
     }
int d1 = n / 16;
     int d2 = n % 16;
     return hexDigits[d1] + hexDigits[d2];
  }

/**
   * J 编码
   *
   * @param origin
   * @return
   */

  // MessageDigest JDK 提供的加密类
  public static String MD5Encode(String origin) {
origin =origin.trim();
     String resultString = null;
     try {
resultString = new String(origin);
        MessageDigest md = MessageDigest.getInstance("MD5");
        resultString = byteArrayToHexString(md.digest(resultString
              .getBytes("UTF-8")));
     } catch (Exception ex) {
}
return resultString;
  }


public static void main(String[] args) {
}
}

时间工具类

package com.fuiou.pay.client.util;

import java.text.SimpleDateFormat;

public class DateUtils {

public static String getCurrentDate(String aFormat) {
String tDate = new SimpleDateFormat(aFormat).format(new java.util.Date(System.currentTimeMillis()));
       return tDate;
   }

public static String getCurrentDate() {
return DateUtils.getCurrentDate("yyyyMMdd");
   }
public static String getCurrentTime() {
return DateUtils.getCurrentDate("HHmmss");
   }
public static String getCurrentDateAndTime() {
return DateUtils.getCurrentDate("yyyyMMddHHmmss");
   }

public static String getNewRandomCode(int codeLen) {
//首先定义随机数据源
     //根据需要得到的数据码的长度返回随机字符串
     java.util.Random randomCode = new java.util.Random();
     String strCode = "";
     while (codeLen > 0) {
int charCode=randomCode.nextInt(9);
        strCode += charCode;
        codeLen--;
     }
return strCode;
  }


public static void main(String[] args) {
System.out.println(getNewRandomCode(20));
  }
}

了解了相应的接口文档.


明天计划的事情:(一定要写非常细致的内容) 

进行方案设计.
遇到的问题:(遇到什么困难,怎么解决的) 

对PM的原型图还是有点头晕...



返回列表 返回列表
评论

    分享到