(String sSrc)
| 40 | |
| 41 | |
| 42 | public String decrypt(String sSrc) throws Exception { |
| 43 | try { |
| 44 | byte[] raw = sKey.getBytes("ASCII"); |
| 45 | SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); |
| 46 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); |
| 47 | IvParameterSpec iv = new IvParameterSpec(ivParameter.getBytes()); |
| 48 | cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv); |
| 49 | byte[] encrypted1 = CBase64.decode(sSrc, CBase64.DEFAULT);//先用base64解密 |
| 50 | byte[] original = cipher.doFinal(encrypted1); |
| 51 | String originalString = new String(original,"utf-8"); |
| 52 | return originalString; |
| 53 | } catch (Exception ex) { |
| 54 | return null; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | public static void main(String[] args) throws Exception { |
| 59 | // 需要加密的字符串 |
no test coverage detected