liusheng
昨天 28446c1489c8977d634e7a39dbbc96967e22c6f1
ruoyi-common/src/main/java/com/ruoyi/common/utils/AesUtils.java
@@ -16,7 +16,7 @@
    /** 算法/模式/填充 */
    private static final String ALGORITHM = "AES/CBC/PKCS5Padding";
    /** 默认 Key(HEX,32字节→256位密钥) */
    /** 默认 Key(HEX,16字节→128位密钥) */
    private static final String DEFAULT_KEY = "0F471C56362408AF8DB929C38EDFD23C";
    /** 默认 IV(HEX,16字节→128位偏移量) */
@@ -101,7 +101,7 @@
    // -------------------------------------------------------------------------
    /**
     * HEX 字符串转字节数组(大小写均可)
     * HEX 字符串转字节数组(大小写均可),不足 16 字节自动补 0
     */
    private static byte[] hexToBytes(String hex) {
        if (hex == null || hex.length() % 2 != 0) {
@@ -113,6 +113,12 @@
            data[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4)
                    + Character.digit(hex.charAt(i + 1), 16));
        }
        // IV 不足 16 字节时补 0(兼容第三方 8 字节 IV)
        if (data.length < 16) {
            byte[] padded = new byte[16];
            System.arraycopy(data, 0, padded, 0, data.length);
            data = padded;
        }
        return data;
    }