| | |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.net.util.Base64; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @ClassName AESUtil |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | public class AESUtils { |
| | | //密钥 |
| | | public static String key = "AD42F7787B035B7580000EF93BE20BAD"; |
| | | public static String key ; |
| | | //字符集 |
| | | private static String charset = "utf-8"; |
| | | // 偏移量 |
| | |
| | | //AES种类 |
| | | private static String transformation = "AES/CBC/PKCS5Padding"; |
| | | private static String algorithm = "AES"; |
| | | |
| | | |
| | | @Value("${AES.KEY}") |
| | | public void setKey(String key) { |
| | | AESUtils.key = key; |
| | | } |
| | | |
| | | |
| | | |
| | | //加密 |
| | | public static String encrypt(String content) { |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(encrypt("4048974139","AD42F7787B035B7580000EF93BE20BAD")); |
| | | System.out.println(encrypt("chenkaiyu111","AD42F7787B035B7580000EF93BE20BAD")); |
| | | // System.out.println(encrypt("123456","AD42F7787B035B7580000EF93BE20BAD")); |
| | | //123456 KoWjfDMZQhJMLlG1crBPqQ== |
| | | // 部分提交 |
| | | String str = decrypt("KoWjfDMZQhJMLlG1crBPqQ==", "AD42F7787B035B7580000EF93BE20BAD"); |
| | | System.out.println(str); |
| | | } |
| | | |
| | | } |