Input length must be multiple of 8 when decrypting with padded cipher 错误

1. Problem description

Use TrueLicense to create an authorization function, import the generated certificate file into the program, and report the following error as soon as it starts:

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
	at com.sun.crypto.provider.CipherCore.prepareInputBuffer(CipherCore.java:1005)
	at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:848)
	at com.sun.crypto.provider.PBES1Core.doFinal(PBES1Core.java:423)
	at com.sun.crypto.provider.PBEWithMD5AndDESCipher.engineDoFinal(PBEWithMD5AndDESCipher.java:316)
	at javax.crypto.Cipher.doFinal(Cipher.java:2164)
	at de.schlichtherle.license.PrivacyGuard.key2cert(PrivacyGuard.java:169)

Two, the solution

Reporting this error is basically a problem with your ciphertext. Check carefully to see if it has been escaped or not. I am using a file. I didn’t pay attention at first.

insert image description here
After debugging, I didn't find any problems. After working for a long time, I finally found that it was caused by this file, and I was drunk. . . The file in the resources directory is 1kb, but it becomes 2kb in the classes directory after packaging... This is obviously modified

insert image description here
It must be caused by maven. Through the following plug-in, you can filter out the file and let maven not do any processing on the file.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/classes</outputDirectory>
                            <useDefaultDelimiters>true</useDefaultDelimiters>
                            <resources>
                                <resource>
                                    <directory>${
    
    basedir}/src/main/resources</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                            <nonFilteredFileExtensions>
                                <!-- xxx文件后缀名,不被filter打包时编码 -->
                                <nonFilteredFileExtension>lic</nonFilteredFileExtension>
                                <nonFilteredFileExtension>keystore</nonFilteredFileExtension>
                            </nonFilteredFileExtensions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Supongo que te gusta

Origin blog.csdn.net/mashangzhifu/article/details/122524746
Recomendado
Clasificación