Skip to content

Commit

Permalink
BUG for decrypt password
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Mar 30, 2015
1 parent 7c19b59 commit 94a7598
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions sigla-ejb/src/main/java/it/cnr/contab/util/StringEncrypter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public final class StringEncrypter {

private static final String UNICODE_FORMAT = "UTF8";

public static void main(String[] args) throws EncryptionException {
System.out.println(encrypt("protocollo.adrba@pec.cnr.it", "adrba-h501e"));
}
private static KeySpec getKeySpec( String encryptionKey ) throws EncryptionException
{
String encryptionScheme = DESEDE_ENCRYPTION_SCHEME;
Expand Down Expand Up @@ -113,7 +116,7 @@ public static String decrypt( String encryptionKey, String encryptedString ) thr
byte[] cleartext = Base64.decode( encryptedString );
byte[] ciphertext = cipher.doFinal( cleartext );

return bytes2String( ciphertext );
return new String( ciphertext );
}
catch (NoSuchAlgorithmException e)
{
Expand All @@ -129,16 +132,6 @@ public static String decrypt( String encryptionKey, String encryptedString ) thr
}
}

private static String bytes2String( byte[] bytes )
{
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < bytes.length; i++)
{
stringBuffer.append( (char) bytes[i] );
}
return stringBuffer.toString();
}

@SuppressWarnings("serial")
public static class EncryptionException extends Exception
{
Expand All @@ -148,3 +141,4 @@ public EncryptionException( Throwable t )
}
}
}

0 comments on commit 94a7598

Please sign in to comment.