Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Use char[] in example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Schwab committed Mar 27, 2020
1 parent a0e83cc commit c2a354e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/de/db/bcm/tupw/TUPW.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
* 2019-03-07: V4.0.1: Strengthen test for invalid blinding data. fhs
* 2019-03-07: V4.1.0: Correct handling of keys with subject parameter. fhs
* 2020-03-06: V4.1.1: Simply read from System.in. fhs
* 2020-03-27: V4.1.2: Adapted to new interface.. fhs
* 2020-03-27: V4.1.2: Adapted to new interface. fhs
* 2020-03-27: V4.1.3: Show usage with char[] on decryption. fhs
*/
package de.db.bcm.tupw;

Expand All @@ -48,6 +49,7 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;

/**
* Example program to calculate the encryption of user and password for
Expand All @@ -61,7 +63,7 @@
* </p>
*
* @author Frank Schwab, DB Systel GmbH
* @version 4.1.2
* @version 4.1.3
*/
public class TUPW {
private static final int MAX_INPUT_BYTES = 50000000;
Expand Down Expand Up @@ -117,7 +119,12 @@ public static void main(final String[] args) {
if (args[0].substring(0, 1).toLowerCase().equals("e")) {
System.out.println(myEncryptor.encryptData(getInputFromWhereEver(args[itemIndex]), subject));
} else {
System.out.println(myEncryptor.decryptDataAsString(getInputFromWhereEver(args[itemIndex]), subject));
final char[] decryptedOutput = myEncryptor.decryptDataAsCharacterArray(getInputFromWhereEver(args[itemIndex]), subject);

System.out.println(decryptedOutput);

// Clear decrypted output after use
Arrays.fill(decryptedOutput, '\0');
}
} catch (final Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit c2a354e

Please sign in to comment.