0

i'm trying to use Apache common.codec library to do some encryption in java, here is a sample code snippet:

    String password = "abc124";
    String salt = "$1$69$";
    String cryptedPassword = org.apache.commons.codec.digest.Md5Crypt.md5Crypt(password.getBytes(), salt);
    System.out.println(cryptedPassword);

And my .pom files CURRENTLY contains only this dependency:

<dependencies>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.9</version>
    </dependency>
</dependencies>

When i try to execute that code snippet, i obtain this strange and uncommon error:

Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.apache.commons.codec.digest.DigestUtils.getMd5Digest()Ljava/security/MessageDigest; from class org.apache.commons.codec.digest.Md5Crypt at org.apache.commons.codec.digest.Md5Crypt.md5Crypt(Md5Crypt.java:196) at org.apache.commons.codec.digest.Md5Crypt.md5Crypt(Md5Crypt.java:161) at Tester.main

I've tried to update library version to 1.10, with same issue. I've also tried do upgrade java version, that, currently is:

java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

javac-version javac 1.8.0_131

And my environment is running on OSX.

  • https://stackoverflow.com/questions/34449400/org-apache-commons-codec-digest-md5crypt-md5crypt-function-exception-occured-un – Darshan Mehta May 25 '17 at 22:29
  • Thanks for your search, but no one of that solution is my real case. i'm not currently using tomcat, and my library was downloaded freshly directly from maven repository. – Antonio Scalzo May 25 '17 at 22:36

0 Answers0