That fuck shit the fascists are using
at master 37 lines 1.0 kB view raw
1package org.tm.archive.backup; 2 3 4import androidx.annotation.NonNull; 5import androidx.annotation.Nullable; 6 7import org.greenrobot.eventbus.EventBus; 8import org.signal.libsignal.protocol.util.ByteUtil; 9 10import java.security.MessageDigest; 11import java.security.NoSuchAlgorithmException; 12 13public abstract class FullBackupBase { 14 15 private static final int DIGEST_ROUNDS = 250_000; 16 17 static class BackupStream { 18 static @NonNull byte[] getBackupKey(@NonNull String passphrase, @Nullable byte[] salt) { 19 try { 20 MessageDigest digest = MessageDigest.getInstance("SHA-512"); 21 byte[] input = passphrase.replace(" ", "").getBytes(); 22 byte[] hash = input; 23 24 if (salt != null) digest.update(salt); 25 26 for (int i = 0; i < DIGEST_ROUNDS; i++) { 27 digest.update(hash); 28 hash = digest.digest(input); 29 } 30 31 return ByteUtil.trim(hash, 32); 32 } catch (NoSuchAlgorithmException e) { 33 throw new AssertionError(e); 34 } 35 } 36 } 37}