91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.06KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-02-01
  • 標(biāo)簽: java??AES??MD5??ES??AE??

資源簡介

1、JAVA MD5加密,AES加密解決;

2、項(xiàng)目需求,根據(jù)用戶ID,軟件名稱,時間,硬件ID生成隨機(jī)6位碼,用戶ID是可逆的。 基本思路是,兩位存儲用戶ID,其他四位隨機(jī)加密碼,然后再講兩位 和四位二次混淆加密。

/ 自定義加密六位碼 母本
private static String CUSTKEY = "56789Q0TYW2prxaER1U3Oz4IPASDuiowcvnFGHtyJsdfKLZXghjkeCVbBNMqm";

/**
* 根據(jù) 輸入 字符串 輸出四位隨機(jī)數(shù)

* @param input
* @return
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static String Rarefy_Encrypt(String input) {
try {
String encrypt = MD5_Encrypt(input);
String result = "";
byte[] bytes = encrypt.getBytes("utf-8");
for (int i = 0; i < 4; i )// 每八位 字節(jié)相加對61取余數(shù) ,取custkey中的內(nèi)容
{
int t = (bytes[i 0] bytes[i 1] bytes[i 2]
bytes[i 3] bytes[i 4] bytes[i 5]
bytes[i 6] bytes[i 7]);
int t1 = t % 61;
result = CUSTKEY.charAt(t1);

}
return result;
} catch (Exception ex) {
ex.printStackTrace();
return "";

}
}

/**
* 將兩位用戶ID插入4位加密密碼中 可逆的 返回6位

* @param source
*            四位密碼
* @param insert
*            兩位用戶ID
* @return
*/
public static String Insert_Encrypt(String source, String insert) {
try {
// XYXXX YY
// [][][][][][]
String t1 = source.substring(0, 2);
String t2 = source.substring(2,4);

byte[] temp1 = t1.getBytes("utf-8");
byte[] temp2 = t2.getBytes("utf-8");
int index1 = (temp1[0] temp1[1]) % 2;// 奇數(shù):1 偶數(shù):2
int index2 = (temp2[0] temp2[1]) % 2;// 奇數(shù):4,偶數(shù):5
char[] result = new char[6];

if (index1 > 0) {
result[0] = source.charAt(0);
result[1] = insert.charAt(0);
result[2] = source.charAt(1);
} else {

result[0] = source.charAt(0);
result[1] = source.charAt(1);
result[2] = insert.charAt(0);
}
if (index2 > 0) {
result[3] = source.charAt(2);
result[4] = insert.charAt(1);
result[5] = source.charAt(3);
} else {
result[3] = source.charAt(2);
result[4] = source.charAt(3);
result[5] = insert.charAt(1);
}
return new String(result);
} catch (Exception ex) {
ex.printStackTrace();
return "";
}
}

/**
* 將 兩位 用戶ID從 六位加密中取出, 返回 string【】 0:4位密碼 ;1:兩位用戶名ID

* @param decryptStr
*            6位加密字符
* @param source
*            4位原始加密碼
* @return
*/
public static String[] Insert_Decrypt(String decryptStr, String source) {
try {
String t1 = source.substring(0, 2);
String t2 = source.substring(2, 4);
byte[] temp1 = t1.getBytes("utf-8");
byte[] temp2 = t2.getBytes("utf-8");
int index1 = (temp1[0] temp1[1]) % 2;// 基數(shù):1 偶數(shù):2
int index2 = (temp2[0] temp2[1]) % 2;// 基數(shù):4,偶數(shù):5
char[] encrypt = new char[4];
char[] userid = new char[2];
if (index1 > 0) {
// result[0] = source[0];
// result[1] = insert[0];
// result[2] = source[1];
userid[0] = decryptStr.charAt(1);
encrypt[0] = decryptStr.charAt(0);
encrypt[1] = decryptStr.charAt(2);
} else {
// result[0] = source[0];
// result[1] = source[1];
// result[2] = insert[0];
userid[0] = decryptStr.charAt(2);
encrypt[0] = decryptStr.charAt(0);
encrypt[1] = decryptStr.charAt(1);
}
if (index2 > 0) {
// result[3] = source[2];
// result[4] = insert[1];
// result[5] = source[3];
encrypt[2] = decryptStr.charAt(3);
encrypt[3] = decryptStr.charAt(5);
userid[1] = decryptStr.charAt(4);
} else {
// result[3] = source[2];
// result[4] = source[3];
// result[5] = insert[1];
encrypt[2] = decryptStr.charAt(3);
encrypt[3] = decryptStr.charAt(4);
userid[1] = decryptStr.charAt(5);
}
String[] result = new String[2];
result[0] = new String(encrypt);
result[1] = new String(userid);
return result;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}

}

資源截圖

代碼片段和文件信息

package?encrypt;

import?java.security.MessageDigest;
import?java.security.NoSuchAlgorithmException;
import?java.io.UnsupportedEncodingException;
import?javax.crypto.Cipher;
import?javax.crypto.spec.SecretKeySpec;
import?javax.crypto.spec.IvParameterSpec;
import?sun.misc.base64Decoder;
import?com.sun.org.apache.xerces.internal.impl.dv.util.base64;

/**
?*?通用加密解密算法
?*?
?*?@author?kwg?2017-8-22
?*?
?*/
public?class?Crypto?{

/**
?*?MD5不可逆加密算法
?*?
?*?@param?encryptString
?*?@return
?*?@throws?NoSuchAlgorithmException
?*?@throws?UnsupportedEncodingException
?*/
public?static?String?MD5_Encrypt(String?encryptString)?{

try?{
if?(““.equals(encryptString))
return?““;
MessageDigest?md?=?MessageDigest.getInstance(“MD5“);

byte[]?result?=?md.

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????I.A....??????7062??2020-02-11?15:33??Crypto.java

-----------?---------??----------?-----??----

?????????????????7062????????????????????1


評論

共有 條評論