sdwyw123 2019-10-02 21:48 采纳率: 66.7%
浏览 485
已采纳

请问这段代码最终得出的getKey()的值是什么

package com.ahtv.application;

import android.util.Base64;
import java.io.PrintStream;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class CryptAES
{
  public static String jmkey = "VatC3b0zAqpLmAkE";

  public static String decrypt(String paramString1, String paramString2)
  {
    try
    {
      SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramString2.getBytes(), "AES");
      Cipher localCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
      localCipher.init(2, localSecretKeySpec);
      byte[] arrayOfByte2 = localCipher.doFinal(Base64.decode(paramString1, 0));
      arrayOfByte1 = arrayOfByte2;
    }
    catch (Exception localException)
    {
      for (;;)
      {
        System.out.println(localException.toString());
        byte[] arrayOfByte1 = null;
      }
    }
    return new String(arrayOfByte1);
  }

  public static String encrypt(String paramString1, String paramString2)
  {
    try
    {
      SecretKeySpec localSecretKeySpec = new SecretKeySpec(paramString2.getBytes(), "AES");
      Cipher localCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
      localCipher.init(1, localSecretKeySpec);
      byte[] arrayOfByte2 = localCipher.doFinal(paramString1.getBytes());
      arrayOfByte1 = arrayOfByte2;
    }
    catch (Exception localException)
    {
      for (;;)
      {
        System.out.println(localException.toString());
        byte[] arrayOfByte1 = null;
      }
    }
    return new String(Base64.encodeToString(arrayOfByte1, 0));
  }

  public static String getKey()
  {
    if ((jmkey != null) || (!"".equals(jmkey)))
    {
      char[] arrayOfChar1 = jmkey.toCharArray();
      char[] arrayOfChar2 = new char[jmkey.length()];
      for (int i = 0; i < arrayOfChar1.length; i++) {
        arrayOfChar2[i] = arrayOfChar1[(-1 + arrayOfChar1.length - i)];
      }
      return new String(arrayOfChar2);
    }
    return "EkAmLpqAz0b3CtaV";
  }

  public static void main(String[] paramArrayOfString)
  {
    System.out.println(getKey());
  }
}
  • 写回答

2条回答 默认 最新

  • zqbnqsdsmd 2019-10-02 23:25
    关注

    没错,我在as里运行了,就是是EkAmLpqAz0b3CtaV

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?