diff --git a/.classpath b/.classpath index bb3192f..70bdf99 100644 --- a/.classpath +++ b/.classpath @@ -8,5 +8,6 @@ + diff --git a/src/it/HackerInside/TextEncryptionUtility/AES256.java b/src/it/HackerInside/TextEncryptionUtility/AES256.java index 17a8536..4628650 100644 --- a/src/it/HackerInside/TextEncryptionUtility/AES256.java +++ b/src/it/HackerInside/TextEncryptionUtility/AES256.java @@ -21,6 +21,9 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Base32; + import technology.zeroalpha.security.pgpwordlist.InvalidHexValueException; import technology.zeroalpha.security.pgpwordlist.PGPWordListConverter; @@ -162,6 +165,12 @@ public static String encryptDecryptString(int mode, String input, SecretKey key, }else if(encoding.equalsIgnoreCase("base36")) {// Base36 Encoding return Base36.encode(os.toByteArray()); + }else if(encoding.equalsIgnoreCase("base32")) {// Base32 Encoding + Base32 base32 = new Base32(); + return base32.encodeAsString(os.toByteArray()); + }else if(encoding.equalsIgnoreCase("base32-c")) {// Base32-C Encoding + Base32 base32 = new Base32(); + return base32.encodeAsString(os.toByteArray()).replace('=', '9'); } else { return bytesToHex(os.toByteArray()); @@ -188,6 +197,13 @@ else if(mode==Cipher.DECRYPT_MODE){ } }else if(encoding.equalsIgnoreCase("base36")) {// Base36 Decoding decodedData = Base36.decode(input); + }else if(encoding.equalsIgnoreCase("base32")) {// Base32 Encoding + Base32 base32 = new Base32(); + decodedData = base32.decode(input); + }else if(encoding.equalsIgnoreCase("base32-c")) { // Base32-C + Base32 base32 = new Base32(); + input = input.replace('9', '='); + decodedData = base32.decode(input); } is = new BufferedInputStream(new ByteArrayInputStream(decodedData)); diff --git a/src/it/HackerInside/TextEncryptionUtility/Settings_Window.java b/src/it/HackerInside/TextEncryptionUtility/Settings_Window.java index dae66cd..39ab16b 100644 --- a/src/it/HackerInside/TextEncryptionUtility/Settings_Window.java +++ b/src/it/HackerInside/TextEncryptionUtility/Settings_Window.java @@ -131,7 +131,7 @@ private void initialize() { cmbEncoding.setBounds(93, 11, 200, 36); panel.add(cmbEncoding); - cmbEncoding.setModel(new DefaultComboBoxModel(new String[] {"Base64", "Base58", "Hex", "PGP Word list", "Base36"})); + cmbEncoding.setModel(new DefaultComboBoxModel(new String[] {"Base64", "Base58", "Hex", "PGP Word list", "Base36", "Base32", "Base32-C"})); JCheckBox chckbCompression = new JCheckBox("GZIP Compression"); chckbCompression.setBackground(Color.WHITE); diff --git a/src/it/HackerInside/TextEncryptionUtility/TextEncryptionUtil_Main.java b/src/it/HackerInside/TextEncryptionUtility/TextEncryptionUtil_Main.java index f59ba95..c21ac52 100644 --- a/src/it/HackerInside/TextEncryptionUtility/TextEncryptionUtil_Main.java +++ b/src/it/HackerInside/TextEncryptionUtility/TextEncryptionUtil_Main.java @@ -39,7 +39,6 @@ import java.security.Security; import java.security.cert.CertificateException; import java.util.Enumeration; -import java.util.Random; import java.util.Scanner; import java.util.prefs.Preferences; import java.awt.event.MouseWheelEvent; @@ -230,8 +229,11 @@ public void actionPerformed(ActionEvent e) { String encryptedData = ""; int encoding = prefs.getInt("encoding", 0); encryptedData = txtbData.getText().toString(); + + encryptedData = encryptedData.replace("\n", ""); + encryptedData = encryptedData.replace("\r", ""); - if(encoding !=3) // Rimuove gli spazi se e solo se l'opzione di codifica non è PGP Wordlist + if(encoding !=3) // Rimuove gli spazi se e solo se l'opzione di codifica non è PGP Wordlist encryptedData = encryptedData.replace(" ", ""); try { @@ -349,6 +351,10 @@ else if(encoding == 3) encrypted = AES256.encryptDecryptString(Cipher.ENCRYPT_MODE, text, key,"pgpWordlist",compression); else if(encoding == 4) encrypted = AES256.encryptDecryptString(Cipher.ENCRYPT_MODE, text, key,"base36",compression); + else if(encoding == 5) + encrypted = AES256.encryptDecryptString(Cipher.ENCRYPT_MODE, text, key,"base32",compression); + else if(encoding == 6) + encrypted = AES256.encryptDecryptString(Cipher.ENCRYPT_MODE, text, key,"base32-c",compression); return encrypted; @@ -365,11 +371,14 @@ else if(encoding == 1) decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"base58",compression); else if(encoding == 2) decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"hex",compression); - else if(encoding == 3) decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"pgpWordlist",compression); else if(encoding == 4) decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"base36",compression); + else if(encoding == 5) + decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"base32",compression); + else if(encoding == 6) + decrypted = AES256.encryptDecryptString(Cipher.DECRYPT_MODE, text, key,"base32-c",compression); return decrypted; }