AES解密測試
This commit is contained in:
parent
528647a0bc
commit
59271ce709
31
common/src/main/java/com/yunbao/common/utils/AesUtils.java
Normal file
31
common/src/main/java/com/yunbao/common/utils/AesUtils.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class AesUtils {
|
||||
|
||||
public static String decrypt(String encrypted) {
|
||||
try {
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec("76b60dd0a5d7cafdqqew".getBytes(), "AES");
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
|
||||
byte[] original = cipher.doFinal(hexToByteArray(encrypted));
|
||||
return new String(original);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] hexToByteArray(String hex) {
|
||||
if (hex == null || hex.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
byte[] ba = new byte[hex.length() / 2];
|
||||
for (int i = 0; i < ba.length; i++) {
|
||||
ba[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
|
||||
}
|
||||
return ba;
|
||||
}
|
||||
}
|
@ -60,7 +60,9 @@ import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.bean.QiniuLog;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.server.DownloadService;
|
||||
import com.yunbao.common.utils.AesUtils;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LogUtil;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
@ -579,6 +581,35 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
//获取声网Token
|
||||
getSwToken();
|
||||
initLogUpdate();
|
||||
testAes();
|
||||
}
|
||||
|
||||
private void testAes() {
|
||||
StringBuffer aesStr =new StringBuffer();
|
||||
aesStr.append("U2FsdGVkX18Lsg0B0gFJ2WJMpoOTQSFqwAbpFw+Urz79FED0vnyUrTV4tGgU4jcy\n" +
|
||||
"LjKWKN21rqsedhgt+or527FmkJaoWVmXFbq38XMOnRv5SveAfIas3qoIwUZA2+Zn\n" +
|
||||
"8M+/I7nCYeArHS13zQxhXzvcGrtvWzzem4Ksncf/7/ptaaZH5L8tHksoEewiUqcS\n" +
|
||||
"WVpQeRtuySBMcMbmiq1m2Asmy9JfQYQzDBHT66wTy8RRRUw6F1C7b4dAvc20OMS+\n" +
|
||||
"42cMiBuwb2QmTShBiHICw7dPg1vxjWwVhrpA2xJWBd7YEdvD14RNvQI7RgQvlXDX\n" +
|
||||
"5utpY/bWhmzOs7znLcHNUiQ0U3M1XamYXksy3cti7ARHCJcVJDFBr28lLnt5gu+r\n" +
|
||||
"5QX3yLdK537zaUUVHfTjfFSMdPKaOeguZ+h1SSIVnaPlmKyCj2nidS2RN4e7xBWc\n" +
|
||||
"4DpARaChW0fcYXFyaiCnR3TMmKY02pwdG6x/PGP4OfDp1azJCeZkJD1/mQHwaVjR\n" +
|
||||
"VmNtxaA7i1SB9KMwrugBnvtzFjPcvdQwAaYmqZQr6NZ0ZvHO6luptoVo/YZgtDhx\n" +
|
||||
"AlZ6oFmH2kUpv0hlrfN5TGrLUDcwrFO+NZQgZakNXYbnWz/mHCzIBSzw8XYrxaJx\n" +
|
||||
"JEbiWh15/bHRaEFT/wnnWT5PYi0hH4PTrTaL9s4PhZcS1KJ/E2HJZhDHeGoA97Sg\n" +
|
||||
"CxQhxh3Loi8H85IrfMNr6T40rIRggSKU+svGwQLIzgdp8i80QhGpFsC9P4BMy9VG\n" +
|
||||
"PjYaqHHGK+s4vPo7nug27DLa5XMO0COH3l0mzg+NMkZKFsWSY5MnM4FAtScf762w\n" +
|
||||
"Wb9RIIBUFnKlH7HWiXl/Ex92+QZnyVs/S2f2jeWiRTRixoRZZcgaRNoiK1Blumop\n" +
|
||||
"wXu0lO3cr303ug/B+0OiROdNmmPh3nvjuBopTxqPQd42YVbcKfx8UAVt55pXrszA\n" +
|
||||
"IrnuHeQUfXqIeUHCtOLSeyxi7eK8ztVyEOmKyG7ho9KqmpR7EvVEtcPHVCj/J1rf\n" +
|
||||
"1tIZl3efl1vBSJj5UzpPXTDXdmojODnxZyZqkXc8H2fqPRCcaS7HqMnPkln1BLCh\n" +
|
||||
"8Eon6QAT8lXBLHSnPLlCVDOG1ZteE2xPwi4745NF5Tz2i1D8mZPvUIgZaV73D1WR\n" +
|
||||
"cdGDMG9s+okiMx2K5imiOyH6VjHixrsiuxYmPvDGEGetIJKUmrhTXHjXQUMMP/wx\n" +
|
||||
"dASbECKoO0ic7k7PwwE8Ekpo7zVtK7tkmYUwA6Fi2VBLiwS0r89H+9gTw9dJfsqR\n" +
|
||||
"HcyiWOuP/z/Pzaaoa3XqvjLZYGAtCFJac0MRFZAHsWtZw8tz+KCYw3nG+RDCXmKC\n" +
|
||||
"jpzU4/Jv9ARo8vQAdBm+Dw==");
|
||||
String msg = AesUtils.decrypt(aesStr.toString());
|
||||
L.e("解密:"+msg);
|
||||
}
|
||||
|
||||
private void getSwToken() {
|
||||
|
Loading…
Reference in New Issue
Block a user