Skip to content

Commit

Permalink
Using async
Browse files Browse the repository at this point in the history
  • Loading branch information
gohj99 committed Aug 3, 2024
1 parent 57c0b00 commit e7f2854
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# 希沃管家密码破解工具

希沃管家密码破解工具是一个用Kotlin和Jetpack Compose编写的软件,旨在帮助用户恢复希沃管家的密码。该项目的灵感和部分代码来自于[Seewo Assistant Password Recovery Tool V2](https://github.com/zhy8388608/Seewo_Assistant_Password_Recovery_Tool_V2)
希沃管家密码破解工具是一个用Kotlin和Jetpack Compose编写的软件,旨在帮助破解希沃管家的密码。该项目的灵感和部分代码来自于[Seewo Assistant Password Recovery Tool V2](https://github.com/zhy8388608/Seewo_Assistant_Password_Recovery_Tool_V2)

## 使用方法

1. 从你的电脑中找到`LockPasswardV2`的值。该值通常位于以下路径之一:
- `C:\ProgramData\Seewo\SeewoCore\SeewoCore.ini`
- `%APPDATA%\Seewo\SeewoAbility\SeewoLockConfig.ini`
2. 打开对应的`.ini`文件,找到`LockPasswardV2``PASSWORDV2`字段,并记录其值。
3. 将记录的`LockPasswardV2``PASSWORDV2`值粘贴到软件的输入框中。
4. 点击“计算”按钮,软件将开始计算密码(该过程可能需要5分钟以内的时间)。

## 技术栈

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdk = 21
targetSdk = 34
versionCode = 1
versionName = "1.0.0"
versionName = "1.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
104 changes: 72 additions & 32 deletions app/src/main/java/site/gohj99/seewoaprt/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import site.gohj99.seewoaprt.ui.theme.seewoaprtTheme
import java.security.MessageDigest
import java.util.concurrent.atomic.AtomicBoolean

class MainActivity : ComponentActivity() {
private var doneStr = mutableStateOf("")
private val md5Digest: MessageDigest = MessageDigest.getInstance("MD5")
private var isComputing = mutableStateOf(false)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -58,37 +61,68 @@ class MainActivity : ComponentActivity() {
SplashMainScreen(
onDoneClick = { text ->
lifecycleScope.launch {
isComputing.value = true
doneStr.value = getString(R.string.loading)
val recoveredPassword = seewoAssistantPasswordRecovery(text)
val recoveredPassword = seewoAssistantPasswordRecovery(
lockPasswordV2 = text
)
if (recoveredPassword != null) {
doneStr.value = recoveredPassword
doneStr.value = getString(R.string.result) + recoveredPassword
} else {
doneStr.value = getString(R.string.failed)
}
isComputing.value = false
}
},
doneStr = doneStr
doneStr = doneStr,
isComputing = isComputing
)
}
}
doneStr.value = getString(R.string.count)
}

private suspend fun seewoAssistantPasswordRecovery(LockPasswordV2: String): String? = withContext(Dispatchers.Default) {
private suspend fun seewoAssistantPasswordRecovery(lockPasswordV2: String): String? = withContext(Dispatchers.Default) {
if (lockPasswordV2 == "") {
return@withContext null
}
val hugo = toMD5("hugo")
for (i in 0 until 1000000) {
val pwd = "%06d".format(i)
val enc = toMD5(toMD5(pwd) + hugo).substring(8, 24)
if (enc == LockPasswordV2) {
return@withContext pwd
val totalParts = 3000
val rangeSize = 1000000 / totalParts
val found = AtomicBoolean(false)
val deferredResults = (0 until totalParts).map { part ->
async {
val start = part * rangeSize
val end = start + rangeSize
for (i in start until end) {
if (found.get()) {
return@async null
}
val pwd = "%06d".format(i)
val enc = toMD5(toMD5(pwd) + hugo).substring(8, 24)
if (enc == lockPasswordV2) {
found.set(true)
return@async pwd
}
}
return@async null
}
}
return@withContext null
deferredResults.awaitAll().firstOrNull { it != null }
}

private fun toMD5(input: String): String {
val bytes = MessageDigest.getInstance("MD5").digest(input.toByteArray())
return bytes.joinToString("") { "%02x".format(it) }
val digest = md5Digest.clone() as MessageDigest
val bytes = digest.digest(input.toByteArray())
val hexString = StringBuilder(bytes.size * 2)
for (byte in bytes) {
val hex = (byte.toInt() and 0xFF).toString(16)
if (hex.length == 1) {
hexString.append('0')
}
hexString.append(hex)
}
return hexString.toString()
}
}

Expand All @@ -97,31 +131,34 @@ fun CustomButton(
onClick: () -> Unit,
text: String,
modifier: Modifier = Modifier,
shape: androidx.compose.foundation.shape.RoundedCornerShape = androidx.compose.foundation.shape.RoundedCornerShape(10.dp)
shape: RoundedCornerShape = RoundedCornerShape(10.dp),
enabled: Boolean = true
) {
var isPressed by remember { mutableStateOf(false) }
val scale by animateFloatAsState(if (isPressed) 0.9f else 1f)
val scale by animateFloatAsState(if (isPressed && enabled) 0.9f else 1f, label = "")

Box(
modifier = modifier
.scale(scale)
.size(width = 148.dp, height = 33.dp)
.clip(shape)
.background(Color(0xFF2397D3))
.background(if (enabled) Color(0xFF2397D3) else Color.Gray)
.pointerInput(Unit) {
detectTapGestures(
onPress = {
isPressed = true
try {
awaitRelease()
} finally {
isPressed = false
if (enabled) {
detectTapGestures(
onPress = {
isPressed = true
try {
awaitRelease()
} finally {
isPressed = false
}
},
onTap = {
onClick()
}
},
onTap = {
onClick()
}
)
)
}
},
contentAlignment = Alignment.Center
) {
Expand All @@ -135,7 +172,8 @@ fun CustomButton(
@Composable
fun SplashMainScreen(
onDoneClick: (String) -> Unit,
doneStr: MutableState<String>
doneStr: MutableState<String>,
isComputing: MutableState<Boolean>
) {
val passwordHint: String = stringResource(id = R.string.PasswardV2)
var text by remember { mutableStateOf("") }
Expand Down Expand Up @@ -163,9 +201,9 @@ fun SplashMainScreen(
.padding(start = 30.dp, end = 30.dp)
.background(
color = Color.Gray,
shape = androidx.compose.foundation.shape.RoundedCornerShape(4.dp)
shape = RoundedCornerShape(4.dp)
)
.clip(androidx.compose.foundation.shape.RoundedCornerShape(4.dp))
.clip(RoundedCornerShape(4.dp))
) {
BasicTextField(
value = text,
Expand Down Expand Up @@ -205,7 +243,8 @@ fun SplashMainScreen(
onClick = {
onDoneClick(text)
},
text = doneStr.value
text = doneStr.value,
enabled = !isComputing.value
)
}
}
Expand All @@ -216,7 +255,8 @@ fun GreetingPreview() {
seewoaprtTheme {
SplashMainScreen(
onDoneClick = { /*TODO*/ },
doneStr = mutableStateOf("")
doneStr = mutableStateOf(""),
isComputing = mutableStateOf(false)
)
}
}

0 comments on commit e7f2854

Please sign in to comment.