Skip to content

Commit

Permalink
Don't use JAXB for converting bytes to hex string (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdebsk committed Dec 8, 2017
1 parent f3a0222 commit 620ef70
Showing 1 changed file with 2 additions and 6 deletions.
Expand Up @@ -16,23 +16,20 @@
package org.fedoraproject.xmvn.resolver.impl;

import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import javax.xml.bind.annotation.adapters.HexBinaryAdapter;

/**
* @author Mikolaj Izdebski
*/
class CacheManager
{
private static final String DIGEST_ALGORITHM = "SHA-1";

private final HexBinaryAdapter hexAdapter;

private final MessageDigest digest;

private static volatile Path cacheHome;
Expand All @@ -41,7 +38,6 @@ public CacheManager()
{
try
{
hexAdapter = new HexBinaryAdapter();
digest = MessageDigest.getInstance( DIGEST_ALGORITHM );
}
catch ( NoSuchAlgorithmException e )
Expand All @@ -58,7 +54,7 @@ private String hash( Path path )

String hash( byte[] bytes )
{
return hexAdapter.marshal( digest.digest( bytes ) );
return new BigInteger( 1, digest.digest( bytes ) ).setBit( 160 ).toString( 16 ).substring( 1 ).toUpperCase();
}

private static Path getPathDefault( String key, Object defaultValue )
Expand Down

0 comments on commit 620ef70

Please sign in to comment.