This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/*
This is the java program to generate N passwords each of length M given by the user. The number of passwords, N, returned doesn’t exceed M!.
Here is the source code of the Java Program to G
*/
//This is sample program to generate N passwords of length M, where N < M!
importjava.util.Random;
importjava.util.Scanner;
publicclassN_Password_M_Length
{
staticvoidpermute(int[]a,intk)
{
if(k==a.length)
{
for(inti=0;i<a.length;i++)
{
System.out.print(a[i]);
}
System.out.println();
}
else
{
for(inti=k;i<a.length;i++)
{
inttemp=a[k];
a[k]=a[i];
a[i]=temp;
permute(a,k+1);
temp=a[k];
a[k]=a[i];
a[i]=temp;
}
}
}
publicstaticvoidmain(Stringargs[])
{
System.out.println("Enter the length of the password: ");
Scannerinput=newScanner(System.in);
intm=input.nextInt();
Randomrandom=newRandom();
int[]a=newint[m];
for(inti=0;i<m;i++)
{
a[i]=random.nextInt(10);
}
System.out.println("The Possible Passwords are: ");