91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

AESUtils實現了基于AES的ECB模式,選用了zeropadding填充,數據位為128 加上密碼去加解密數據,優化并實測通過

資源截圖

代碼片段和文件信息

package?com.larcloud.sdk.encrypt;

import?org.apache.commons.codec.binary.base64;

import?javax.crypto.Cipher;
import?javax.crypto.spec.SecretKeySpec;

/**
?*?AES加解密工具類
?*/
public?class?AESUtils?{
????private?static?final?String?KEY_ALGORITHM?=?“AES“;
????private?static?final?String?DEFAULT_CIPHER_ALGORITHM?=?“AES/ECB/NoPadding“;//默認的加密算法

????/**
?????*?AES?加密操作
?????*
?????*?@param?content?待加密內容
?????*?@param?password?加密密碼
?????*?@return?返回base64轉碼后的加密數據
?????*/
????public?static?String?encrypt(String?content?String?password)?{
????????try?{
????????????Cipher?cipher?=?Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);//?創建密碼器
????????????int?blockSize?=?cipher.getBlockSize();

????????????byte[]?byteContent?=?content.getBytes();

????????????int?plaintextLength?=?byteContent.length;
????????????if(plaintextLength?%?blockSize?!=?0)
????????????{
????????????????plaintextLength?=?plaintextLength?+?(blockSize?-?(plaintextLength?%?blockSize));
????????????}

????????????byte[]?plaintext?=?new?byte[plaintextLength];
????????????System.arraycopy(byteContent?0?plaintext?0?byteContent.length);

????????????//?生成加密秘鑰
????????????SecretKeySpec?keySpec?=?getSecretKey(password);

????????????cipher.init(Cipher.ENCRYPT_MODE?keySpec);//?初始化為加密模式的密碼器

????????????byte[]?result?=?cipher.doFinal(plaintext);//?加密

????????????return?base64.encodebase64String(result);//通過base64轉碼返回
????????}?catch?(Exception?ex)?{
????????????ex.p

評論

共有 條評論