public class AESUtil {
// 加密
public static byte[] Encrypt(String sSrc, String sKey) throws Exception {
if (sKey == null) {
System.out.print("Key为空null");
return null;
}
byte[] raw = new byte[16];
byte[] src = new byte[16];
if (sKey.length() == 16) {
raw = sKey.getBytes("utf-8");
}
if (sKey.length() < 16 && sKey.length() > 0) {
byte[] bytes = sKey.getBytes();
int length = bytes.length;
byte[] data2 = new byte[16 - length];
raw = StringUtils.addBytes(bytes, data2);
}
if (sSrc.length() == 16) {
src = sKey.getBytes("utf-8");
}
if (sSrc.length() < 16 && sSrc.length() > 0) {
byte[] bytes = sSrc.getBytes();
int length = bytes.length;
byte[] data2 = new byte[16 - length];
src = StringUtils.addBytes(bytes, data2); //数组合并,主要是补齐到16位,这里必须是16位的整数
}
SecretKeySpec skeySpec &#
JAVA AES加密 NoPadding的填充方式
最新推荐文章于 2024-05-26 14:34:02 发布