Created
May 14, 2024 15:40
-
-
Save TesteurManiak/549a6f97bf864a7ab7426918cbfe7e35 to your computer and use it in GitHub Desktop.
Dart version of the Tachiyomi algorithm used to generate source ids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| import 'dart:math'; | |
| import 'package:crypto/crypto.dart'; | |
| int generateId(String name, String lang, int versionId) { | |
| String key = "${name.toLowerCase()}/$lang/$versionId"; | |
| List<int> bytes = md5.convert(utf8.encode(key)).bytes; | |
| int result = 0; | |
| for (int i = 0; i < 8; i++) { | |
| result |= (bytes[i] & 0xff) << (8 * (7 - i)); | |
| } | |
| return result & (pow(2, 63).toInt() - 1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment