|
|
|
@ -1,8 +1,13 @@ |
|
|
|
package com.ccsens.util; |
|
|
|
|
|
|
|
import cn.hutool.core.codec.Base64; |
|
|
|
import cn.hutool.core.lang.Console; |
|
|
|
import cn.hutool.core.util.ZipUtil; |
|
|
|
import cn.hutool.crypto.symmetric.SymmetricAlgorithm; |
|
|
|
import cn.hutool.crypto.symmetric.SymmetricCrypto; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import io.swagger.annotations.ApiModelProperty; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.junit.Test; |
|
|
|
import sun.misc.BASE64Decoder; |
|
|
|
@ -12,6 +17,7 @@ import sun.misc.BASE64Encoder; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.security.MessageDigest; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: |
|
|
|
@ -22,6 +28,8 @@ import java.io.FileOutputStream; |
|
|
|
public class Base64Test { |
|
|
|
|
|
|
|
|
|
|
|
private static Object TestEncrypt; |
|
|
|
|
|
|
|
@Test |
|
|
|
public void test01() throws Exception { |
|
|
|
File file = new File("d:" + File.separator + "1.png"); |
|
|
|
@ -118,4 +126,45 @@ public class Base64Test { |
|
|
|
System.out.println(((Class)c.getClass().getField("TYPE").get(null)).isPrimitive()); |
|
|
|
} |
|
|
|
|
|
|
|
public static class TestEncrypt{ |
|
|
|
private Long p = 1386496320902139904L; |
|
|
|
private Long r = 1386496320902139904L; |
|
|
|
} |
|
|
|
|
|
|
|
/**加密*/ |
|
|
|
@Test |
|
|
|
public void test3()throws Exception{ |
|
|
|
String string1 = Md5Util.stringTo(JSONObject.toJSONString(Base64Test.TestEncrypt)); |
|
|
|
System.out.println(string1); |
|
|
|
// SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(key));
|
|
|
|
// String encryptHex = aes.encryptHex(string);
|
|
|
|
// System.out.println(encryptHex);
|
|
|
|
String s = Base64Test.shaEncode(JSONObject.toJSONString(Base64Test.TestEncrypt)); |
|
|
|
System.out.println(s); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static String shaEncode(String inStr) throws Exception { |
|
|
|
MessageDigest sha = null; |
|
|
|
try { |
|
|
|
sha = MessageDigest.getInstance("SHA"); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println(e.toString()); |
|
|
|
e.printStackTrace(); |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
byte[] byteArray = inStr.getBytes("UTF-8"); |
|
|
|
byte[] md5Bytes = sha.digest(byteArray); |
|
|
|
StringBuffer hexValue = new StringBuffer(); |
|
|
|
for (int i = 0; i < md5Bytes.length; i++) { |
|
|
|
int val = ((int) md5Bytes[i]) & 0xff; |
|
|
|
if (val < 16) { |
|
|
|
hexValue.append("0"); |
|
|
|
} |
|
|
|
hexValue.append(Integer.toHexString(val)); |
|
|
|
} |
|
|
|
return hexValue.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|