From 81f0783c63f7b62544f59f29dc0fce449dd79fb3 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Wed, 22 Jan 2020 22:47:19 +0800 Subject: [PATCH] fix(Bencode): Fix dict keys may not in sorted order refs: https://wiki.theory.org/index.php/BitTorrentSpecification#Dictionaries --- application/Libraries/Bencode/Bencode.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/Libraries/Bencode/Bencode.php b/application/Libraries/Bencode/Bencode.php index 40504b8..8bdee13 100644 --- a/application/Libraries/Bencode/Bencode.php +++ b/application/Libraries/Bencode/Bencode.php @@ -108,6 +108,7 @@ public static function encode($data): string } } else { $return .= 'd'; + ksort($data, SORT_STRING); foreach ($data as $key => $value) { $return .= self::encode(strval($key)); $return .= self::encode($value);