初学者问一行JAVA代码的含义

莫某菜鸟 发布于 2014/11/12 09:49
阅读 579
收藏 0
private static String a(String paramString1, String paramString2, String paramString3)
  {
    String str1 = "username=" + paramString1 + ",pwd=" + paramString2 + ",uuid=" + paramString3;
    com.jd.b.a.a locala = new com.jd.b.a.a();
    try
    {
            String str2 = com.jd.b.a.a.a(locala.a( str1)).toUpperCase();//这行代码的含义?两次调用构造函数?
      return str2;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    return "";
  }



下面的是引用包的源码

package com.jd.b.a;
 
import java.security.NoSuchProviderException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
 
public final class a
{
  IvParameterSpec a = new IvParameterSpec(this.b);
  private final byte[] b = "3#6q0/bj".getBytes();
  private SecretKey c;
  private Cipher d;
 
  public a()
  {
    try
    {
      DESKeySpec localDESKeySpec = new DESKeySpec("3#6q0/bj".getBytes());
      this.c = SecretKeyFactory.getInstance("DES").generateSecret(localDESKeySpec);
      this.d = Cipher.getInstance("DES/CBC/PKCS5Padding");
      this.d.init(1, this.c, this.a);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
      return;
    }
    catch (NoSuchProviderException localNoSuchProviderException)
    {
      localNoSuchProviderException.printStackTrace();
    }
  }
 
  public static String a(byte[] paramArrayOfByte)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    for (int i = 0; i < paramArrayOfByte.length; i++)
    {
      String str = Integer.toHexString(0xFF & paramArrayOfByte[i]);
      if (str.length() < 2)
        str = "0" + str;
      localStringBuffer.append(str);
    }
    return localStringBuffer.toString();
  }
 
  public final byte[] a(String paramString)
  {
    try
    {
      byte[] arrayOfByte = this.d.doFinal(paramString.getBytes());
      return arrayOfByte;
    }
    catch (BadPaddingException localBadPaddingException)
    {
      localBadPaddingException.printStackTrace();
      return null;
    }
    catch (IllegalBlockSizeException localIllegalBlockSizeException)
    {
      while (true)
        localIllegalBlockSizeException.printStackTrace();
    }
  }
}






加载中
0
vvtf
vvtf
fucking the 'a' object.
0
开源中国投资人
开源中国投资人
我擦。。。这事京东的代码?面像对象的抽像,在这段代码里体现的淋漓尽致啊。。
0
开源中国搬砖小能手
开源中国搬砖小能手

这样写代码看起来太乱了,先改一下

import com.jd.b.a;

............................

private static String a(String paramString1, String paramString2, String paramString3)
  {
    String str1 = "username=" + paramString1 + ",pwd=" + paramString2 + ",uuid=" + paramString3;
    a locala = new a();
    try
    {
            String str2 = a.a(locala.a( str1)).toUpperCase();//这行代码的含义?两次调用构造函数?
      return str2;
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    return "";
  }

然后代码就成这样了

String str2 = a.a(locala.a(str1)).toUpperCase();

内层的locala.a(strq)是调用local对象的当中的public final byte[] a(String paramString)方法,原因是它传入的参数是String类型的。

外层的a.a(locala.a(str1))的是调用a这个类的静态方法public static String a(byte[] paramArrayOfByte),原因是locala.a(strq)的返回值是byte[],正好是外部静态a方法的参数类型,并且通过类名就只能调用类当中的静态方法

这里牵扯到了一些方法重载和静态方法的知识,说的不好,见谅.....


0
战天诛
战天诛

京东的代码写这鸟样?

b.a.a.b.b.a.a.b

还没高中生写得好

Shazi199
Shazi199
代码混淆都不知道就不要来喷了吧
0
r
roywang
反编译的?
0
Shazi199
Shazi199

混淆过的代码反编译来的吧?这种没营养的东西就不要看了

0
筱龙缘
筱龙缘
加密该字串  然后全大写
0
阿阿阿飞
阿阿阿飞
加密字符串,然后全大写,看见这包名就醉了
返回顶部
顶部