能力值:
( LV2,RANK:10 )
|
-
-
2 楼
已经解决
|
能力值:
( LV5,RANK:70 )
|
-
-
3 楼
文本转utf-8 加密KEY是sdtyffdftesfyfdw
然后加密文本.得到的16进制转字符输出而已
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
已经解决
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
已经解决
|
能力值:
( LV2,RANK:10 )
|
-
-
6 楼
已经解决
|
能力值:
( LV2,RANK:10 )
|
-
-
7 楼
已经解决
|
能力值:
( LV2,RANK:10 )
|
-
-
8 楼
C.encrypt(要加密的内容, 秘钥[就是哪个C.k])
|
能力值:
( LV2,RANK:10 )
|
-
-
9 楼
number:13800138000 encrypt num:C69F44F281B1199B6546CB21CA7FF080
|
能力值:
( LV2,RANK:10 )
|
-
-
10 楼
已经解决
|
能力值:
( LV7,RANK:100 )
|
-
-
11 楼
电脑上使用要替换jce_policy,JDK_HOME\jre\lib\security,下面是jce_policy下载地址
jdk1.5:http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-plat-419418.html#jce_policy-1.5.0-oth-JPR
jdk1.6:http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html
jdk1.7:http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
jdk1.8:http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
编译:javac AES.java
运行:java AES
import java.io.UnsupportedEncodingException;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class AES {
private static final String CipherMode = "AES/ECB/PKCS5Padding";
public static String k = "sdtyffdftesfyfdw";
private static SecretKeySpec createKey(String key) {
byte[] bArr = null;
if (key == null) {
key = "";
}
StringBuffer sb = new StringBuffer(32);
sb.append(key);
while (sb.length() < 32) {
sb.append("0");
}
if (sb.length() > 32) {
sb.setLength(32);
}
try {
bArr = sb.toString().getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return new SecretKeySpec(bArr, "AES");
}
public static byte[] encrypt(byte[] bArr, String key) {
try {
SecretKeySpec seckey = AES.createKey(key);
System.out.println(seckey);
Cipher instance = Cipher.getInstance(CipherMode);
instance.init(Cipher.ENCRYPT_MODE, seckey);
return instance.doFinal(bArr);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String encrypt(String str, String key) {
byte[] bArr = null;
try {
bArr = str.getBytes("UTF-8");
} catch (Exception e) {
e.printStackTrace();
}
return AES.byte2hex(AES.encrypt(bArr, key));
}
public static byte[] decrypt(byte[] bArr, String key) {
try {
SecretKeySpec seckey = AES.createKey(key);
Cipher instance = Cipher.getInstance(CipherMode);
instance.init(Cipher.DECRYPT_MODE, seckey);
return instance.doFinal(bArr);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String decrypt(String str, String key) {
byte[] bArr = null;
try {
bArr = AES.hex2byte(str);
} catch (Exception e) {
e.printStackTrace();
}
bArr = AES.decrypt(bArr, key);
if (bArr == null) {
return null;
}
try {
return new String(bArr, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public static String byte2hex(byte[] bArr) {
StringBuffer sb = new StringBuffer(bArr.length * 2);
String hex = "";
for (byte b : bArr) {
hex = Integer.toHexString(b & 255);
if (hex.length() == 1) {
sb.append("0");
}
sb.append(hex);
}
return sb.toString().toUpperCase();
}
private static byte[] hex2byte(String hex) {
if (hex == null || hex.length() < 2) {
return new byte[0];
}
hex = hex.toLowerCase();
int len = hex.length() / 2;
byte[] bArr = new byte[len];
for (int i = 0; i < len; i++) {
bArr[i] = (byte) (Integer.parseInt(hex.substring(2 * i, (2 * i) + 2), 16) & 255);
}
return bArr;
}
public static void main(String[] args) {
String s = AES.encrypt("13249582075", AES.k);
System.out.println(s);
s = AES.decrypt(s, k);
System.out.println(s);
}
}
|
能力值:
( LV2,RANK:10 )
|
-
-
12 楼
求密钥
|
|
|