package com.cm.params;

import com.cm.security.utils.AesUtil;
import com.cm.token.IToken;
import org.apache.commons.codec.binary.Base64;

/**
 * @author Administrator
 * @version 1.0
 * @className ParamsIn
 * @description TODO
 * @date 2018/12/7 18:06
 **/
public class ParamsIn {

    /**
     * 提交参数加密
     *
     * @param params
     * @return
     * @throws Exception
     */
    public static String paramsInEncode(String params) throws Exception {
        return Base64.encodeBase64String(AesUtil.aesEncoder("cmxxParamsIn", params).getBytes(IToken.CHARSET_NAME_UTF_8));
    }

    /**
     * 相应参数解密
     *
     * @param outParams
     * @return
     * @throws Exception
     */
    public static String paramsOutDecoder(String outParams) throws Exception {
        return AesUtil.aesDecoder("cmxxParamsOut", new String(Base64.decodeBase64(outParams), IToken.CHARSET_NAME_UTF_8));
    }

}
