| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import javax.crypto.*; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.SecureRandom; |
| | | |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.KeyGenerator; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | |
| | | /** |
| | | * AES加密解密 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class AESUtil { |
| | | |
| | |
| | | cipher.init(Cipher.ENCRYPT_MODE, key); |
| | | // 加密 |
| | | byte[] result = cipher.doFinal(byteContent); |
| | | return (new sun.misc.BASE64Encoder()).encode(result); |
| | | return StringUtil.getBase64FromByte(result); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } catch (NoSuchPaddingException e) { |