From 72583e54cb3823e2d86f0d80d7cc587f102e62ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 22 Mar 2016 15:00:52 +0100 Subject: DB: add checkDigest(...) --- core/src/ch/asynk/rustanddust/util/DB.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index 18ee162..df2a64c 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -121,6 +121,14 @@ public class DB return hash; } + private boolean checkDigest(String what, int id, String payload, String digest) + { + if (digest.equals(getDigest(payload))) + return true; + RustAndDust.error(String.format("corrupted %s(%d)", what, id)); + return false; + } + private static final String CHECK_VERSION = "select (value=%d) from config where key='version';"; public Boolean checkVersion() -- cgit v1.1-2-g2b99