/**
     * PKCS7填充
     * @param sourceData 原文数据对应的字节数组
     * @param blockSize  分组大小(比如国密SM4算法的分组大小是16字节)
     * @return
     */
    public static byte[] PKCS7Padding(byte[] sourceData, int blockSize) {
        int newLong = (sourceData.length / blockSize + 1) * blockSize;
        byte[] ret = new byte[newLong];
        System.arraycopy(sourceData, 0, ret, 0, sourceData.length);
        for (int i = sourceData.length; i < ret.length; ++i) {
            ret[i] = (byte) (ret.length - sourceData.length);
        }
        return ret;
    }

    public static void main(String[] args) {
        String str = "1";
        // 使用PKCS7填充
        byte[] b1 = PKCS7Padding(str.getBytes(), 16);
        System.out.println("填充后的大小(byte):" + b1.length + "  填充后的数据(经过Base64编码):" + Base64.getEncoder().encodeToString(b1));

    }