Redman31100
Messages postés167Date d'inscriptionmardi 11 septembre 2007StatutMembreDernière intervention11 février 2009
-
26 mars 2008 à 18:31
Redman31100
Messages postés167Date d'inscriptionmardi 11 septembre 2007StatutMembreDernière intervention11 février 2009
-
5 sept. 2008 à 00:45
Si quelqu'un pouvez me le traduire SVP ca serait bien, j'en ai besoin pour une alternative de générateur de mot de passe, par exemple on prend un nombre aléatoire et a x boucle on prend le mot.
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 27 mars 2008 à 05:17
c'est pas d'une grande complexité, me semble...
void BruteForce(int LongMin, int LongMax)
{
const char ALL[105] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890<>,?;.:/!§*µù%$£¤¨+=})]à@ç^\\_`è|-[({'#"é~&";
int Lg = LongMin - 1;
int i, x, y;
char* Buff = (char*) malloc(Lg); // Creer le Buff de Lg octet
while(Lg != LongMax)
{
realloc(Buff, Lg); // Augmente la taille du buff
int Nchar[Lg];
for(i=0; i<=Lg; i++)
{
Buff[i] = ALL[0]; // Remplie le Buff du premier char
Nchar[i] = 0; // Initialise le tableau de int a 0
}
while(Nchar[0] != 105)
{
for(x=0; x<=105; x++)
{
Buff[Lg] = ALL[x];
Nchar[Lg] = x;
printf("%s \n", Buff);
nbMDP++;
}
for(y=Lg; y>=0; y--)
{
if((Nchar[y] == 105)&&(Nchar[0]!= 105))
{
Nchar[y] = 0;
Nchar[y-1]++;
}
Buff[y] = ALL[Nchar[y]];
}
}
Lg++;
}
free(Buff);// Libere la memoire
}
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 28 mars 2008 à 10:58
Traduire.... le tout est de comprendre l'algo.
je dirai (gaffe, je suis pas expert .Net... ca fonctionne, mais y'a peut etre plus direct.
Private Function BruteForce(ByVal vnLongMin As Integer, ByVal vnLongMax As Integer) As String()
Dim Caractères() As Char = New String("ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz1234567890<>,?;.:/!§*µù%$£¤¨+=})]à@ç^\\_`è|-[({'#""é~&").ToCharArray()
Dim Lg As Integer = vnLongMin - 1
Dim y As Integer
Dim xsRet As Stack(Of String) = New Stack(Of String)
Erase BruteForce
'// Creer le Buff de Lg caractères
For Lg = vnLongMin - 1 To vnLongMax - 1
Dim Buff() As Char = New String("A", Lg + 1).ToCharArray
Dim nChar(Lg) As Integer
Do
For Each c As Char In Caractères
Buff(Lg) = c
xsRet.Push(New String(Buff))
Next c
For y = Lg - 1 To 0 Step -1
nChar(y) += 1
If nChar(y) > Caractères.GetUpperBound(0) Then
nChar(y) = 0
Buff(y) = Caractères(0)
If y = 0 Then
Exit Do
End If
Else
Buff(y) = Caractères(nChar(y))
Exit For
End If
Next y
Loop
Next Lg
ReDim BruteForce(xsRet.Count - 1)
xsRet.CopyTo(BruteForce, 0)
End Function