All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ape9527.core.service.AesService Maven / Gradle / Ivy

The newest version!
package com.ape9527.core.service;

import com.ape9527.core.annotation.CustomizedValue;
import com.ape9527.utils.sign.AesUtil;
import org.springframework.stereotype.Service;

/**
 * AES加解密服务
 *
 * @author YuanShuai[[email protected]]
 */
@Service
public class AesService {

    /**
     * 配置文件中获取16位的密钥
     */
    @CustomizedValue("${ape.crypt.secretKey}")
    private String secretKey;

    /**
     * 数据加密
     * @param content 待加密数据
     * @return 加密后的数据
     * @throws Exception
     */
    public String encrypt(String content) throws Exception {
        return AesUtil.encrypt(content, secretKey);
    }

    /**
     * 数据解密
     * @param encrypted 待解密数据
     * @return 解密后的数据
     * @throws Exception
     */
    public String decrypt(String encrypted) throws Exception {
        return AesUtil.decrypt(encrypted, secretKey);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy