Predictable "random" password

Report a typo

Let's say we are trying to establish encrypted communication with our friend. For this, we will use a secret seed that we agreed on, then generate a 10-character long password and prompt our friend for the same password. If it is indeed our friend, the words will match.

Write a function that takes a known seed and generates a string of exactly 10 random printable characters (codes between 33 and 126 inclusive) using this seed. Use the .toChar() function to convert a random number to a character and join all the characters into a single string.

Tip: Make sure to call the Random constructor only once and reuse the same instance to generate all the numbers.

Tip: Note that code 33 and 126 both need to be included.

Write a program in Kotlin
import kotlin.random.Random

fun generatePredictablePassword(seed: Int): String {
var randomPassword = ""
// write your code here
return randomPassword
}
___

Create a free account to access the full topic