Skip to content

Instantly share code, notes, and snippets.

@IsmailAlamKhan
Last active July 16, 2023 10:51
Show Gist options
  • Save IsmailAlamKhan/72c6878d6966e2078bee0098ce734ce6 to your computer and use it in GitHub Desktop.
Save IsmailAlamKhan/72c6878d6966e2078bee0098ce734ce6 to your computer and use it in GitHub Desktop.
Random code generate
// Generated using Google bard
import 'dart:math';
void main() {
String passcode = generatePasscode();
print('Generated Passcode: $passcode');
}
String generatePasscode({int length = 8, bool useAlphabet = true}) {
Random random = Random();
String randomString = '';
for (int i = 0; i < length; i++) {
if (useAlphabet) {
randomString += String.fromCharCode(random.nextInt(26) + 97);
} else {
randomString += random.nextInt(10).toString();
}
}
return randomString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment