diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils/CryptoHelper.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/CryptoHelper.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java index 44e89d8fc..da34200bf 100644 --- a/src/main/java/de/pixart/messenger/utils/CryptoHelper.java +++ b/src/main/java/de/pixart/messenger/utils/CryptoHelper.java @@ -1,6 +1,7 @@ package de.pixart.messenger.utils; import android.os.Bundle; +import android.util.Base64; import android.util.Pair; import org.bouncycastle.asn1.x500.X500Name; @@ -12,6 +13,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; @@ -96,6 +98,12 @@ public final class CryptoHelper { return Normalizer.normalize(s, Normalizer.Form.NFKC); } + public static String random(int length, SecureRandom random) { + final byte[] bytes = new byte[length]; + random.nextBytes(bytes); + return Base64.encodeToString(bytes, Base64.NO_PADDING | Base64.NO_WRAP); + } + public static String prettifyFingerprint(String fingerprint) { if (fingerprint == null) { return ""; |