| | |
| | | //解密 |
| | | public static String decrypt(String content, String key) { |
| | | try { |
| | | SecretKeySpec skey = new SecretKeySpec(key.getBytes(), algorithm); |
| | | IvParameterSpec iv = new IvParameterSpec(key.getBytes(), 0, offset); |
| | | SecretKeySpec skey = new SecretKeySpec(key.getBytes("utf-8"), algorithm); |
| | | IvParameterSpec iv = new IvParameterSpec(key.getBytes("utf-8"), 0, offset); |
| | | Cipher cipher = Cipher.getInstance(transformation); |
| | | cipher.init(Cipher.DECRYPT_MODE, skey, iv);// 初始化 |
| | | byte[] result = cipher.doFinal(new Base64().decode(content)); |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(encrypt("123456","AD42F7787B035B7580000EF93BE20BAD")); |
| | | // System.out.println(encrypt("123456","AD42F7787B035B7580000EF93BE20BAD")); |
| | | //123456 KoWjfDMZQhJMLlG1crBPqQ== |
| | | // 部分提交 |
| | | String str = decrypt("KoWjfDMZQhJMLlG1crBPqQ==", "AD42F7787B035B7580000EF93BE20BAD"); |
| | | System.out.println(str); |
| | | } |
| | | |
| | | } |