|
14 | 14 | import javax.xml.bind.DatatypeConverter; |
15 | 15 |
|
16 | 16 | import com.sendsafely.exceptions.PublicKeyEncryptionFailedException; |
| 17 | + |
17 | 18 | import org.bouncycastle.bcpg.ArmoredOutputStream; |
18 | 19 | import org.bouncycastle.crypto.AsymmetricBlockCipher; |
19 | 20 | import org.bouncycastle.crypto.AsymmetricCipherKeyPair; |
|
26 | 27 | import org.bouncycastle.crypto.util.PrivateKeyFactory; |
27 | 28 | import org.bouncycastle.crypto.util.PublicKeyFactory; |
28 | 29 | import org.bouncycastle.openpgp.*; |
29 | | -import org.bouncycastle.openpgp.PGPCompressedData; |
30 | | -import org.bouncycastle.openpgp.PGPEncryptedDataGenerator; |
31 | | -import org.bouncycastle.openpgp.PGPEncryptedDataList; |
32 | | -import org.bouncycastle.openpgp.PGPException; |
33 | | -import org.bouncycastle.openpgp.PGPLiteralData; |
34 | | -import org.bouncycastle.openpgp.PGPLiteralDataGenerator; |
35 | | -import org.bouncycastle.openpgp.PGPObjectFactory; |
36 | | -import org.bouncycastle.openpgp.PGPPBEEncryptedData; |
37 | | -import org.bouncycastle.openpgp.PGPUtil; |
38 | 30 | import org.bouncycastle.openpgp.operator.PBEDataDecryptorFactory; |
39 | 31 | import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator; |
40 | 32 | import org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator; |
|
43 | 35 | import org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder; |
44 | 36 | import org.bouncycastle.util.encoders.Base64; |
45 | 37 | import org.bouncycastle.util.encoders.Hex; |
| 38 | +import org.bouncycastle.util.encoders.UrlBase64; |
46 | 39 |
|
47 | 40 | import com.sendsafely.exceptions.MessageException; |
48 | 41 | import com.sendsafely.exceptions.PublicKeyDecryptionFailedException; |
49 | 42 | import com.sendsafely.exceptions.SignatureCreationFailedException; |
50 | 43 | import com.sendsafely.exceptions.TokenGenerationFailedException; |
| 44 | + |
51 | 45 | import org.bouncycastle.util.io.Streams; |
52 | 46 |
|
53 | 47 | public class CryptoUtil |
@@ -91,8 +85,7 @@ public static String GenerateKeyCode() throws TokenGenerationFailedException |
91 | 85 | } catch (NoSuchProviderException e) { |
92 | 86 | throw new TokenGenerationFailedException(e); |
93 | 87 | } |
94 | | - |
95 | | - return DatatypeConverter.printBase64Binary(randomBytes); |
| 88 | + return new String(UrlBase64.encode(randomBytes)).replace(".", ""); |
96 | 89 | } |
97 | 90 |
|
98 | 91 | public static String PBKDF2(String token, String salt, int iterations) |
|
0 commit comments