// Password Generator in Nyash
// Using RandomBox for secure password generation

print("=== Nyash Password Generator ===")
print("")

// Initialize random generator
rand = new RandomBox()
print("Random generator ready!")

// Create character arrays
lowercase = new ArrayBox()
lowercase.push("a")
lowercase.push("b")
lowercase.push("c")
lowercase.push("d")
lowercase.push("e")
lowercase.push("f")
lowercase.push("g")
lowercase.push("h")
lowercase.push("i")
lowercase.push("j")
lowercase.push("k")
lowercase.push("l")
lowercase.push("m")
lowercase.push("n")
lowercase.push("o")
lowercase.push("p")
lowercase.push("q")
lowercase.push("r")
lowercase.push("s")
lowercase.push("t")
lowercase.push("u")
lowercase.push("v")
lowercase.push("w")
lowercase.push("x")
lowercase.push("y")
lowercase.push("z")

uppercase = new ArrayBox()
uppercase.push("A")
uppercase.push("B")
uppercase.push("C")
uppercase.push("D")
uppercase.push("E")
uppercase.push("F")
uppercase.push("G")
uppercase.push("H")
uppercase.push("I")
uppercase.push("J")
uppercase.push("K")
uppercase.push("L")
uppercase.push("M")
uppercase.push("N")
uppercase.push("O")
uppercase.push("P")
uppercase.push("Q")
uppercase.push("R")
uppercase.push("S")
uppercase.push("T")
uppercase.push("U")
uppercase.push("V")
uppercase.push("W")
uppercase.push("X")
uppercase.push("Y")
uppercase.push("Z")

numbers = new ArrayBox()
numbers.push("0")
numbers.push("1")
numbers.push("2")
numbers.push("3")
numbers.push("4")
numbers.push("5")
numbers.push("6")
numbers.push("7")
numbers.push("8")
numbers.push("9")

symbols = new ArrayBox()
symbols.push("!")
symbols.push("@")
symbols.push("#")
symbols.push("$")
symbols.push("%")
symbols.push("&")
symbols.push("*")
symbols.push("-")
symbols.push("_")
symbols.push("=")
symbols.push("+")

print("Character sets loaded!")
print("Lowercase: " + lowercase.length() + " chars")
print("Uppercase: " + uppercase.length() + " chars") 
print("Numbers: " + numbers.length() + " chars")
print("Symbols: " + symbols.length() + " chars")
print("")

// Combine all characters
allChars = new ArrayBox()

// Add lowercase
i = 0
loop {
    if i >= lowercase.length() {
        break
    }
    char = lowercase.get(i)
    allChars.push(char)
    i = i + 1
}

// Add uppercase
i = 0
loop {
    if i >= uppercase.length() {
        break
    }
    char = uppercase.get(i)
    allChars.push(char)
    i = i + 1
}

// Add numbers
i = 0
loop {
    if i >= numbers.length() {
        break
    }
    char = numbers.get(i)
    allChars.push(char)
    i = i + 1
}

// Add symbols
i = 0
loop {
    if i >= symbols.length() {
        break
    }
    char = symbols.get(i)
    allChars.push(char)
    i = i + 1
}

print("Total character pool: " + allChars.length() + " characters")
print("")

// Generate passwords of different lengths
print("=== Generating Passwords ===")
print("")

// 8 character password
print("8-character password:")
password8 = ""
i = 0
loop {
    if i >= 8 {
        break
    }
    randomChar = rand.choice(allChars)
    password8 = password8 + randomChar
    i = i + 1
}
print(password8)
print("")

// 12 character password
print("12-character password:")
password12 = ""
i = 0
loop {
    if i >= 12 {
        break
    }
    randomChar = rand.choice(allChars)
    password12 = password12 + randomChar
    i = i + 1
}
print(password12)
print("")

// 16 character password
print("16-character password:")
password16 = ""
i = 0
loop {
    if i >= 16 {
        break
    }
    randomChar = rand.choice(allChars)
    password16 = password16 + randomChar
    i = i + 1
}
print(password16)
print("")

// Generate PIN codes
print("=== PIN Codes ===")
pin4 = rand.randInt(1000, 9999)
pin6 = rand.randInt(100000, 999999)
print("4-digit PIN: " + pin4)
print("6-digit PIN: " + pin6)
print("")

// Memorable password (letters + numbers)
print("=== Memorable Style ===")
word1 = rand.choice(lowercase)
word2 = rand.choice(lowercase)
word3 = rand.choice(lowercase)
word4 = rand.choice(lowercase)
num1 = rand.choice(numbers)
num2 = rand.choice(numbers)
symbol1 = rand.choice(symbols)
memorable = word1 + word2 + word3 + word4 + num1 + num2 + symbol1
print("Memorable pattern: " + memorable)
print("")

// Random string using built-in method
print("=== Using randString method ===")
random5 = rand.randString(5)
random10 = rand.randString(10)
random15 = rand.randString(15)
print("5 chars: " + random5)
print("10 chars: " + random10)
print("15 chars: " + random15)
print("")

print("=== Security Info ===")
print("Character pool size: " + allChars.length())
print("Longer passwords = exponentially more secure!")
print("Always use different passwords for different accounts!")
print("")
print("Password generation complete!")