diff --git a/pom.xml b/pom.xml
index a977f1f..fc1b75b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
br.gov.ans.commons
ans-commons-sei
- 1.2.0
+ 1.2.1
ans-commons-sei
jar
Biblioteca de apoio aos clientes do SEI-Broker.
@@ -24,13 +24,6 @@
provided
-
-
- br.gov.ans.commons
- ans-commons-security
- 2.0
-
-
commons-codec
diff --git a/src/main/java/br/gov/ans/sei/utils/SeiHelper.java b/src/main/java/br/gov/ans/sei/utils/SeiHelper.java
index e883408..27acf6c 100644
--- a/src/main/java/br/gov/ans/sei/utils/SeiHelper.java
+++ b/src/main/java/br/gov/ans/sei/utils/SeiHelper.java
@@ -2,59 +2,74 @@ package br.gov.ans.sei.utils;
import java.io.File;
import java.io.FileInputStream;
+import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Base64;
-import br.gov.ans.commons.security.crypt.HashUtils;
-
public class SeiHelper {
/**
* Calcula o hash utilizando o algoritimo SHA-256.
- *
- * @param conteudo entrada da qual será gerado o hash.
+ *
+ * @param conteudo
+ * entrada da qual será gerado o hash.
*
* @return resultado do calculo do hash.
- *
+ *
* @throws NoSuchAlgorithmException
*
*/
- public static String calcularHash(String conteudo) throws NoSuchAlgorithmException{
- return HashUtils.toSHA256(conteudo, null);
+ public static String calcularHash(String conteudo) throws NoSuchAlgorithmException {
+ MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
+
+ byte[] inputBytes = conteudo.getBytes();
+ byte[] inputHash = sha256.digest(inputBytes);
+ StringBuilder sb = new StringBuilder();
+
+ for (int i = 0; i < inputHash.length; i++) {
+ sb.append(Integer.toString((inputHash[i] & 0xff) + 0x100, 16).substring(1));
+ }
+
+ String generatedHash = sb.toString();
+
+ return generatedHash;
}
-
+
/**
* Codifica entrada para Base64.
- *
- * @param bytes Array de bytes que será codificado.
+ *
+ * @param bytes
+ * Array de bytes que será codificado.
*
* @return resultado da conversão dos bytes.
- *
+ *
* @throws NoSuchAlgorithmException
*
*/
- public static String getBase64(byte[] bytes){
+ public static String getBase64(byte[] bytes) {
return Base64.encodeBase64String(bytes);
}
-
+
/**
* Codifica entrada para Base64.
- *
- * @param arquivo File que será codificado.
+ *
+ * @param arquivo
+ * File que será codificado.
*
* @return resultado da conversão dos bytes do arquivo.
- *
+ *
* @throws NoSuchAlgorithmException
*
*/
- public static String getBase64(File arquivo) throws Exception{
- byte[] bytes = new byte[(int) arquivo.length()];
-
- FileInputStream fileInputStream = new FileInputStream(arquivo);
+ public static String getBase64(File arquivo) throws Exception {
+ byte[] bytes = new byte[(int) arquivo.length()];
+
+ FileInputStream fileInputStream = new FileInputStream(arquivo);
fileInputStream.read(bytes);
fileInputStream.close();
-
+
return getBase64(bytes);
}
+
}
--
libgit2 0.21.2