Wednesday, August 21, 2013

java, testing salted hash using the commons-codec

There is one class called DigestUtils in the apache commons-codec, here is a quick how to start tutorial to pickup the jar and do a simple one way hash.

Add a dependency to commons-codec in your pom file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.androidyou</groupId>
    <artifactId>testhash</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.8</version>
        </dependency>

    </dependencies>
</project>


then update the project ,we can see the jar is included in the project

image

image

If you want included the jar in the dependenciy, add one plugin for the assembling

then mvn assembly:assembly you will see the jar with the inlined codec jar files.

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>attached</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
    </plugins>
</build>

No comments:

 
Locations of visitors to this page