Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Generowanie nie losowych stringow
Jabol
post
Post #1





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

Ostrzeżenie: (0%)
-----


Możecie bez strachu przejśc tutaj: http://forum.php.pl/viewtopic.php?p=31706#31706 ;P
[php:1:725d22549f]<?php

$hashes = array();

function get_string()
{
static $string, $depth, $init;
if( ! $init )
{
$init = true;
$string = array( chr( 1 ), chr( 1 ), chr( 1 ), chr( 1 ) );
$depth = 4;
}
else
{
if( ( $char = ++ord( $string[ $depth - 1 ] ) ) > 255 )
{
$string[ $depth - 1 ] = chr( 1 );
for( $i = $depth - 1; $i > 0; $i-- )
if( ++ord( $string[ $i - 1 ] ) > 255 )
{
$string[ $i - 1 ] = chr( 1 );
if( ( $i - 2 == 0 ) && ( ++ord( $string[ 0 ] ) > 255 ) )
{
$string[ ++$depth - 1 ] = chr( 1 );
break;
}
else
$string[ $i - 2 ] = chr( ord( $string[ $i ] ) ++ );
}
else
break;
}
else
$string[ $depth - 1 ] = chr( $char );
}
return implode( '', $string );
}

do
$hashes[ md5( ( $string = get_string() ) ) ] = $string;
while( sizeof( $hashes ) <= pow( 16, 32 ) );

$fd = fopen( 'hashtable', 'w' );
fputs( $fd, serialize( $hashes ) );
fclose( $fd );

?>[/php:1:725d22549f]niech ktoś to przetestuje, może najpierw tylko funkcje get_string(); pisalem bez testowania z glowy, wiec nie wiem czy dziala.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 17:18