论坛首页 编程语言技术论坛

一小段java代码转PHP代码,高手进

浏览 3239 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2018-10-15  
本人对java不熟悉,但这个应该是个字符串加密方法.以php经验try中看得不求甚解,所以求教各位高手!
public static String getMac(String paramString1, String paramString2)
  {
    byte[] arrayOfByte1 = new byte[32];
    arrayOfByte1[0] = 87;
    arrayOfByte1[1] = -77;
    arrayOfByte1[2] = 119;
    arrayOfByte1[3] = 94;
    arrayOfByte1[4] = -103;
    arrayOfByte1[5] = -72;
    arrayOfByte1[6] = -114;
    arrayOfByte1[7] = -108;
    arrayOfByte1[8] = 104;
    arrayOfByte1[9] = -97;
    arrayOfByte1[10] = -11;
    arrayOfByte1[11] = -84;
    arrayOfByte1[12] = 103;
    arrayOfByte1[13] = -59;
    arrayOfByte1[14] = -1;
    arrayOfByte1[15] = -21;
    arrayOfByte1[16] = 113;
    arrayOfByte1[17] = -68;
    arrayOfByte1[18] = -96;
    arrayOfByte1[19] = -57;
    arrayOfByte1[20] = -122;
    arrayOfByte1[21] = 117;
    arrayOfByte1[22] = 73;
    arrayOfByte1[24] = -16;
    arrayOfByte1[25] = -69;
    arrayOfByte1[26] = -79;
    arrayOfByte1[27] = -77;
    arrayOfByte1[28] = 80;
    arrayOfByte1[29] = -98;
    arrayOfByte1[30] = -99;
    arrayOfByte1[31] = 54;
    Object localObject = "";
    try
    {
      Mac localMac = Mac.getInstance("HmacSHA256");
      byte[] arrayOfByte2 = paramString2.getBytes("ASCII");
      localMac.init(new SecretKeySpec(arrayOfByte1, "HMACSHA256"));
      localObject = toHex(localMac.doFinal(arrayOfByte2));
      String str = ((String)localObject).toUpperCase();
      localObject = str;
      return localObject;
    }
    catch (Exception localException)
    {
      while (true)
        localException.printStackTrace();
    }
  }
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics