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
|
// Handle DIGITS
|
||||||
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
||||||
if (!first && RandomNumberGenerator.number(10) < 3) {
|
if (!first && RandomNumberGenerator.number(10) < 3) {
|
||||||
var `val`: String
|
var character: String
|
||||||
do {
|
do {
|
||||||
cha = Character.forDigit(RandomNumberGenerator.number(10), 10)
|
cha = Character.forDigit(RandomNumberGenerator.number(10), 10)
|
||||||
`val` = cha.toString()
|
character = cha.toString()
|
||||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 &&
|
||||||
`val`
|
PasswordGenerator.AMBIGUOUS_STR.contains(character))
|
||||||
)
|
password += character
|
||||||
)
|
|
||||||
password += `val`
|
|
||||||
curSize++
|
curSize++
|
||||||
|
|
||||||
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
||||||
|
@ -183,17 +181,15 @@ internal object Phonemes {
|
||||||
// Handle SYMBOLS
|
// Handle SYMBOLS
|
||||||
if (pwFlags and PasswordGenerator.SYMBOLS > 0) {
|
if (pwFlags and PasswordGenerator.SYMBOLS > 0) {
|
||||||
if (!first && RandomNumberGenerator.number(10) < 2) {
|
if (!first && RandomNumberGenerator.number(10) < 2) {
|
||||||
var `val`: String
|
var character: String
|
||||||
var num: Int
|
var num: Int
|
||||||
do {
|
do {
|
||||||
num = RandomNumberGenerator.number(PasswordGenerator.SYMBOLS_STR.length)
|
num = RandomNumberGenerator.number(PasswordGenerator.SYMBOLS_STR.length)
|
||||||
cha = PasswordGenerator.SYMBOLS_STR.toCharArray()[num]
|
cha = PasswordGenerator.SYMBOLS_STR.toCharArray()[num]
|
||||||
`val` = cha.toString()
|
character = cha.toString()
|
||||||
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
} while (pwFlags and PasswordGenerator.AMBIGUOUS > 0 &&
|
||||||
`val`
|
PasswordGenerator.AMBIGUOUS_STR.contains(character))
|
||||||
)
|
password += character
|
||||||
)
|
|
||||||
password += `val`
|
|
||||||
curSize++
|
curSize++
|
||||||
|
|
||||||
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
||||||
|
|
|
@ -25,7 +25,7 @@ internal object RandomPasswordGenerator {
|
||||||
var i: Int
|
var i: Int
|
||||||
var featureFlags: Int
|
var featureFlags: Int
|
||||||
var num: Int
|
var num: Int
|
||||||
var `val`: String
|
var character: String
|
||||||
|
|
||||||
var bank = ""
|
var bank = ""
|
||||||
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
if (pwFlags and PasswordGenerator.DIGITS > 0) {
|
||||||
|
@ -47,28 +47,26 @@ internal object RandomPasswordGenerator {
|
||||||
while (i < size) {
|
while (i < size) {
|
||||||
num = RandomNumberGenerator.number(bank.length)
|
num = RandomNumberGenerator.number(bank.length)
|
||||||
cha = bank.toCharArray()[num]
|
cha = bank.toCharArray()[num]
|
||||||
`val` = cha.toString()
|
character = cha.toString()
|
||||||
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0 && PasswordGenerator.AMBIGUOUS_STR.contains(
|
if (pwFlags and PasswordGenerator.AMBIGUOUS > 0
|
||||||
`val`
|
&& PasswordGenerator.AMBIGUOUS_STR.contains(character)) {
|
||||||
)
|
|
||||||
) {
|
|
||||||
continue
|
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
|
continue
|
||||||
}
|
}
|
||||||
password += `val`
|
password += character
|
||||||
i++
|
i++
|
||||||
if (PasswordGenerator.DIGITS_STR.contains(`val`)) {
|
if (PasswordGenerator.DIGITS_STR.contains(character)) {
|
||||||
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
featureFlags = featureFlags and PasswordGenerator.DIGITS.inv()
|
||||||
}
|
}
|
||||||
if (PasswordGenerator.UPPERS_STR.contains(`val`)) {
|
if (PasswordGenerator.UPPERS_STR.contains(character)) {
|
||||||
featureFlags = featureFlags and PasswordGenerator.UPPERS.inv()
|
featureFlags = featureFlags and PasswordGenerator.UPPERS.inv()
|
||||||
}
|
}
|
||||||
if (PasswordGenerator.SYMBOLS_STR.contains(`val`)) {
|
if (PasswordGenerator.SYMBOLS_STR.contains(character)) {
|
||||||
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
featureFlags = featureFlags and PasswordGenerator.SYMBOLS.inv()
|
||||||
}
|
}
|
||||||
if (PasswordGenerator.LOWERS_STR.contains(`val`)) {
|
if (PasswordGenerator.LOWERS_STR.contains(character)) {
|
||||||
featureFlags = featureFlags and PasswordGenerator.LOWERS.inv()
|
featureFlags = featureFlags and PasswordGenerator.LOWERS.inv()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue