|
@@ -70,6 +70,7 @@ import androidx.compose.ui.window.DialogProperties
|
|
|
import com.fastest.pass.R
|
|
|
import com.fastest.pass.account.domain.model.SliderPasswordType
|
|
|
import com.fastest.pass.account.domain.model.sliderPasswordTypeList
|
|
|
+import com.google.gson.annotations.SerializedName
|
|
|
import kotlin.math.roundToInt
|
|
|
import kotlin.random.Random
|
|
|
|
|
@@ -845,13 +846,34 @@ fun generatePassword(
|
|
|
val numbers = "0123456789"
|
|
|
val specialCharacters = "!@#$%^&*()-_=+<>?/{}[]|"
|
|
|
|
|
|
- val easyToRead = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789"
|
|
|
+ val easyToReadUC = "ABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
|
+ val easyToReadLC = "abcdefghijkmnopqrstuvwxyz"
|
|
|
+ val easyToReadN = "123456789"
|
|
|
+ val easyToReadSC = "!@#\$%^&*()-_=+<>?/{}[]|"
|
|
|
+
|
|
|
+ val easyToSayUC = "BCDFGHJKLMNPQRSTVWXYZ"
|
|
|
+ val easyToSayLC = "bcdfghjkmnpqrstvwxyz"
|
|
|
|
|
|
var charPool = ""
|
|
|
- if (isLowercaseEnabled) charPool += lowercase
|
|
|
- if (isUppercaseEnabled) charPool += uppercase
|
|
|
- if (isNumbersEnabled) charPool += numbers
|
|
|
- if (isRandomSymbolsEnabled) charPool += specialCharacters
|
|
|
+
|
|
|
+ when (selectedSliderType) {
|
|
|
+ sliderPasswordTypeList[0] -> {
|
|
|
+ if (isLowercaseEnabled) charPool += lowercase
|
|
|
+ if (isUppercaseEnabled) charPool += uppercase
|
|
|
+ if (isNumbersEnabled) charPool += numbers
|
|
|
+ if (isRandomSymbolsEnabled) charPool += specialCharacters
|
|
|
+ }
|
|
|
+ sliderPasswordTypeList[1] -> {
|
|
|
+ if (isLowercaseEnabled) charPool += easyToReadLC
|
|
|
+ if (isUppercaseEnabled) charPool += easyToReadUC
|
|
|
+ if (isNumbersEnabled) charPool += easyToReadN
|
|
|
+ if (isRandomSymbolsEnabled) charPool += easyToReadSC
|
|
|
+ }
|
|
|
+ sliderPasswordTypeList[2] -> {
|
|
|
+ if (isLowercaseEnabled) charPool += easyToSayLC
|
|
|
+ if (isUppercaseEnabled) charPool += easyToSayUC
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
val password = if (charPool.isNotEmpty()) {
|
|
|
(1..passwordLength)
|
|
@@ -868,4 +890,4 @@ fun generatePassword(
|
|
|
Log.d("test_generate_pass", "password = $password")
|
|
|
|
|
|
return password
|
|
|
-}
|
|
|
+}
|