mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-05 08:33:37 +02:00
Check server certificate fingerprint - proof of concept
This commit is contained in:
@@ -628,8 +628,16 @@ public class Helper {
|
||||
return sha256(data.getBytes());
|
||||
}
|
||||
|
||||
static String sha1(byte[] data) throws NoSuchAlgorithmException {
|
||||
return sha("SHA-1", data);
|
||||
}
|
||||
|
||||
static String sha256(byte[] data) throws NoSuchAlgorithmException {
|
||||
byte[] bytes = MessageDigest.getInstance("SHA-256").digest(data);
|
||||
return sha("SHA-256", data);
|
||||
}
|
||||
|
||||
static String sha(String digest, byte[] data) throws NoSuchAlgorithmException {
|
||||
byte[] bytes = MessageDigest.getInstance(digest).digest(data);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes)
|
||||
sb.append(String.format("%02x", b));
|
||||
|
||||
Reference in New Issue
Block a user