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

com.biuqu.encryptor.impl.AesEncryptor Maven / Gradle / Ivy

The newest version!
package com.biuqu.encryptor.impl;

import com.biuqu.encryption.factory.EncryptionFactory;
import com.biuqu.encryptor.BaseSingleEncryptor;
import com.biuqu.encryptor.model.EncryptorKey;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Hex;

/**
 * 国际对称加密算法的加密器
 *
 * @author BiuQu
 * @date 2023/5/3 01:38
 */
public class AesEncryptor extends BaseSingleEncryptor
{
    public AesEncryptor(EncryptorKey key)
    {
        super(EncryptionFactory.AES.createAlgorithm(), Hex.decode(key.getPri()));

        //支持扩展算法
        int encLen = key.getEncryptLen();
        if (encLen > 0)
        {
            this.getEncryption().setEncryptLen(encLen);
        }
        String padding = key.getPadding();
        if (!StringUtils.isEmpty(padding))
        {
            this.getEncryption().setPaddingMode(padding);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy