Random code generen

Gestart doorSanderc16 reacties95 weergaven

17 berichten · pagina 2 van 2

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Je doet het met nummers tot 1000, maar waar is die microtime(), rand(), en ip adres in je string?
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raaoul schreef:
Je doet het met nummers tot 1000, maar waar is die microtime(), rand(), en ip adres in je string?
[COLOR= #0000BB]<?php
$array[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]100000[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<[/COLOR][COLOR= #0000BB]$aantal[/COLOR][COLOR= #007700];[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++)
{[/COLOR]
    [COLOR= #0000BB]$code[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/strtoupper"]strtoupper[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]())),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]]))
    {[/COLOR]
        [COLOR= #0000BB]$array[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]]++;
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [COLOR= #0000BB]$array[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$code[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];
    }
}[/COLOR]
[URL="http://www.php.net/arsort"]arsort[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$o[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$array[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$key[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$value[/COLOR][COLOR= #007700])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$key[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$value[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]"<br />n"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$o[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>


Bovenste resultaten:

E04=43
A80=42
6BB=42
40E=41
9CF=40
9F4=40
5C1=40
CBA=40
07B=40
E45=39
1E2=39
075=39
3E7=39
8DC=38
C16=38
18A=38
89F=38
E23=38
D46=38
AA7=38
15C=38
672=38
CAE=38
506=38
AA4=38
883=38
790=38


Onderste resultaten:

A22=13
B0D=13
55A=13
823=13
F4B=13
FF2=12
590=12
0B3=12
430=12
F72=12
950=11
72F=11
D07=11
6F7=11
F35=11
182=11
13C=10
FE0=10


Even de conclusie. Niet random. Dat wou ik even duidelijk maken, maar opzich kun je het prima gebruiken, maar als je een grotere website met miljoenen random nummers gaat gebruiken gaat het uitmaken.

Alle mogelijke combinaties zijn wel aan de orde geweest. Dus het is niet zo dat er bepaalde combinaties niet mogelijk zijn. Dat bv 13D nooit voorkomt.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren