com.biuqu.encryptor.impl.AesEncryptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bq-encryptor Show documentation
Show all versions of bq-encryptor Show documentation
easy use for mostly encryption
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