From eb970dc9f199acaa003abd517fbdc736563021e8 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 23 Oct 2018 15:45:01 +0200 Subject: decode_datetime(): Fix incorrect encoded & IV string splitting I was using `rsplitn` to split the encoded value into an encrypted timestamp and initialisation vector. Originally, I had used `splitn`, but upon discovering `rsplitn` decided to use that instead to ensure we captured the initialisation vector first, and that anything else would be captured to a single string. Didn't realise, though, that `rsplitn` orders element in reverse order compared to `splitn`. Correct the capture order. --- src/trial.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/trial.rs b/src/trial.rs index 38c8a82..0d94108 100644 --- a/src/trial.rs +++ b/src/trial.rs @@ -150,8 +150,8 @@ fn decode_datetime( s: &str ) -> result::Result, DateCryptError> { let encrypted: Vec<_> = s.rsplitn(2, "//").collect(); - let timestamp = encrypted[0]; - let iv = encrypted[1]; + let timestamp = encrypted[1]; + let iv = encrypted[0]; let mut mc = MagicCrypt::new(KEY, magic_crypt::SecureBit::Bit64, Some(&iv)); -- cgit v1.2.3