diff --git a/src/main/kotlin/fr/shikkanime/utils/EncryptionManager.kt b/src/main/kotlin/fr/shikkanime/utils/EncryptionManager.kt index 946beba1..82937453 100644 --- a/src/main/kotlin/fr/shikkanime/utils/EncryptionManager.kt +++ b/src/main/kotlin/fr/shikkanime/utils/EncryptionManager.kt @@ -35,4 +35,10 @@ object EncryptionManager { val hash = digest.digest(source.toByteArray(StandardCharsets.UTF_8)) return hash.fold("") { str, it -> str + "%02x".format(it) } } + + fun toMD5(source: String): String { + val digest = MessageDigest.getInstance("MD5") // NOSONAR + val hash = digest.digest(source.toByteArray(StandardCharsets.UTF_8)) + return hash.fold("") { str, it -> str + "%02x".format(it) } + } } \ No newline at end of file diff --git a/src/main/kotlin/fr/shikkanime/wrappers/ThreadsWrapper.kt b/src/main/kotlin/fr/shikkanime/wrappers/ThreadsWrapper.kt index 7f386395..986fce8a 100644 --- a/src/main/kotlin/fr/shikkanime/wrappers/ThreadsWrapper.kt +++ b/src/main/kotlin/fr/shikkanime/wrappers/ThreadsWrapper.kt @@ -110,9 +110,9 @@ class ThreadsWrapper( } fun generateDeviceId(username: String, password: String): String { - val seed: String = EncryptionManager.toSHA512(username + password) + val seed: String = EncryptionManager.toMD5(username + password) val volatileSeed = "12345" - return "android-" + EncryptionManager.toSHA512(seed + volatileSeed).substring(0, 16) + return "android-" + EncryptionManager.toMD5(seed + volatileSeed).substring(0, 16) } suspend fun login(deviceId: String, username: String, password: String): Pair { diff --git a/src/test/kotlin/fr/shikkanime/wrappers/ThreadsWrapperTest.kt b/src/test/kotlin/fr/shikkanime/wrappers/ThreadsWrapperTest.kt index 6b41aae2..10b216fe 100644 --- a/src/test/kotlin/fr/shikkanime/wrappers/ThreadsWrapperTest.kt +++ b/src/test/kotlin/fr/shikkanime/wrappers/ThreadsWrapperTest.kt @@ -19,7 +19,7 @@ class ThreadsWrapperTest { fun generateDeviceId() { val username = "Hello" val password = "World!" - assertEquals("android-da88e3773489b230", threadsWrapper.generateDeviceId(username, password)) + assertEquals("android-6f36600bd3a8126c", threadsWrapper.generateDeviceId(username, password)) } @Test