Skip to content

Commit 63e7e32

Browse files
Cambiato il layout a GroupLayout e aggiornata la codifica delle chiavi pubbliche ECDH
Passaggio dal layout fisso a GroupLayout, aggiornata la codifica delle chiavi pubbliche ECDH da Base64 a Base32-c
1 parent 74e1e1e commit 63e7e32

3 files changed

Lines changed: 248 additions & 78 deletions

File tree

src/it/HackerInside/TextEncryptionUtility/Ecdh.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
import java.util.*;
1111
import java.nio.ByteBuffer;
12-
import java.util.Base64;
1312
import javax.crypto.*;
1413
import javax.crypto.spec.SecretKeySpec;
14+
import org.apache.commons.codec.binary.Base32;
1515

1616

1717
public class Ecdh {
@@ -26,11 +26,15 @@ public Ecdh(int bitSize) throws NoSuchAlgorithmException {
2626
}
2727

2828
public String getPublicKey() {
29-
return Base64.getEncoder().encodeToString(ourPk);
29+
Base32 base32 = new Base32();
30+
return base32.encodeAsString(ourPk).replace('=', '9');
3031
}
3132

3233
public byte[] generateSharedSecret(String otherPkBase64) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
33-
byte[] otherPk = Base64.getDecoder().decode(otherPkBase64);
34+
Base32 base32 = new Base32();
35+
36+
otherPkBase64 = otherPkBase64.replace('9', '=');
37+
byte[] otherPk = base32.decode(otherPkBase64);
3438

3539
KeyFactory kf = KeyFactory.getInstance("EC");
3640
X509EncodedKeySpec pkSpec = new X509EncodedKeySpec(otherPk);

0 commit comments

Comments
 (0)