pwgen: Cleanup some variable declarations
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
4169af453b
commit
c9dc4034f1
2 changed files with 20 additions and 26 deletions
|
@ -160,15 +160,13 @@ internal object Phonemes {
|
|||
// Handle DIGITS
|
||||
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
||||
if (!first && RandomNumberGenerator.number(10) < 3) {
|
||||
var `val`: String
|
||||
var character: String
|
||||
do {
|
||||
cha = Character.forDigit(RandomNumberGenerator.number(10), 10)
|
||||
`val` = cha.toString()
|
||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||
`val`
|
||||
)
|
||||
)
|
||||
password += `val`
|
||||
character = cha.toString()
|
||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 &&
|
||||
PasswordGenerator.AMBIGUOUS_STR.contains(character))
|
||||
password += character
|
||||
curSize++
|
||||
|
||||
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
||||
|
@ -183,17 +181,15 @@ internal object Phonemes {
|
|||
// Handle SYMBOLS
|
||||
if (pwFlags and PasswordGenerator.SYMBOLS > 0) {
|
||||
if (!first && RandomNumberGenerator.number(10) < 2) {
|
||||
var `val`: String
|
||||
var character: String
|
||||
var num: Int
|
||||
do {
|
||||
num = RandomNumberGenerator.number(PasswordGenerator.SYMBOLS_STR.length)
|
||||
cha = PasswordGenerator.SYMBOLS_STR.toCharArray()[num]
|
||||
`val` = cha.toString()
|
||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||
`val`
|
||||
)
|
||||
)
|
||||
password += `val`
|
||||
character = cha.toString()
|
||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 &&
|
||||
PasswordGenerator.AMBIGUOUS_STR.contains(character))
|
||||
password += character
|
||||
curSize++
|
||||
|
||||
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
||||
|
|
|
@ -25,7 +25,7 @@ internal object RandomPasswordGenerator {
|
|||
var i: Int
|
||||
var featureFlags: Int
|
||||
var num: Int
|
||||
var `val`: String
|
||||
var character: String
|
||||
|
||||
var bank = ""
|
||||
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
||||
|
@ -47,28 +47,26 @@ internal object RandomPasswordGenerator {
|
|||
while (i < size) {
|
||||
num = RandomNumberGenerator.number(bank.length)
|
||||
cha = bank.toCharArray()[num]
|
||||
`val` = cha.toString()
|
||||
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
||||
`val`
|
||||
)
|
||||
) {
|
||||
character = cha.toString()
|
||||
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0
|
||||
&& PasswordGenerator.AMBIGUOUS_STR.contains(character)) {
|
||||
continue
|
||||
}
|
||||
if (pwFlags and PasswordGenerator.NO_VOWELS > 0 && PasswordGenerator.VOWELS_STR.contains(`val`)) {
|
||||
if (pwFlags and PasswordGenerator.NO_VOWELS > 0 && PasswordGenerator.VOWELS_STR.contains(character)) {
|
||||
continue
|
||||
}
|
||||
password += `val`
|
||||
password += character
|
||||
i++
|
||||
if (PasswordGenerator.DIGITS_STR.contains(`val`)) {
|
||||
if (PasswordGenerator.DIGITS_STR.contains(character)) {
|
||||
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
||||
}
|
||||
if (PasswordGenerator.UPPERS_STR.contains(`val`)) {
|
||||
if (PasswordGenerator.UPPERS_STR.contains(character)) {
|
||||
featureFlags = featureFlags and PasswordGenerator.UPPERS.inv()
|
||||
}
|
||||
if (PasswordGenerator.SYMBOLS_STR.contains(`val`)) {
|
||||
if (PasswordGenerator.SYMBOLS_STR.contains(character)) {
|
||||
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
||||
}
|
||||
if (PasswordGenerator.LOWERS_STR.contains(`val`)) {
|
||||
if (PasswordGenerator.LOWERS_STR.contains(character)) {
|
||||
featureFlags = featureFlags and PasswordGenerator.LOWERS.inv()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue