⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.java

📁 采用JAVA开发
💻 JAVA
字号:
package com.gctech.cmpp3.util;

import com.gctech.util.MD5;
import org.apache.log4j.Logger;
import com.gctech.util.Tools;

/**
 * <p>Title: 短信 API</p>
 * <p>Description: 短信SP API</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: GCTECH</p>
 * @author 王红宝
 * @version $Id: Util.java,v 1.3 2004/05/24 06:13:10 wanghb Exp $
 */

public class Util {

  public static void copy(String src, byte[] data, int destPos){
    if ( src != null ){
      byte[] temp = src.getBytes();
      System.arraycopy(temp, 0, data, destPos, temp.length);
    }
  }

  public Util() {
  }
  /**
   * md5 连接回复。
   * */
  public static byte[] md5ConnectResponse(byte status, byte[] authenSrc,
                                          byte[] sharedSecret){
    logger.debug("status:"+status+",authen:"+Tools.byteArrayToHexString(authenSrc)
                 +",sharedSecret:"+new String(sharedSecret));
    byte[] svrPlain = new byte[17+sharedSecret.length];
    svrPlain[0] = status;
    System.arraycopy(authenSrc, 0, svrPlain, 1, 16);
    System.arraycopy(sharedSecret, 0, svrPlain, 17, sharedSecret.length);
    //做MD5
    MD5 aMd5 = new MD5() ;
    byte[] authenIsmg = aMd5.getMD5ofBytes(svrPlain, svrPlain.length);
    return authenIsmg;

  }
  /**
   * md5 连接认证。
   * */
  public static byte[] md5Connect(
      byte[] spId, byte[] sharedSecret, byte[] timestamp){
    logger.debug(new String(spId));
    logger.debug(new String(sharedSecret));
    logger.debug(new String(timestamp));
    int plainLen = spId.length + 9 + sharedSecret.length + 10;
    byte[] plain = new byte[plainLen];
    //拼凑明文
    System.arraycopy(spId, 0, plain, 0, spId.length);
    System.arraycopy(sharedSecret, 0, plain, spId.length + 9, sharedSecret.length);
    System.arraycopy(timestamp, 0, plain, spId.length + 9+sharedSecret.length, 10);

    //做MD5
    MD5 md5 = new MD5() ;
    byte[] md5Msg = md5.getMD5ofBytes(plain, plain.length);
    return md5Msg;
  }
  static final Logger logger = Logger.getLogger(Util.class);
}

⌨️ 快捷键说明

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