StyleGame

Doriți să reacționați la acest mesaj? Creați un cont în câteva clickuri sau conectați-vă pentru a continua.
StyleGame

Online Tutorials

Va rog sa faceti cunoscut forumu. Cum puteti ajuta? De preferat la status pe yahoo messenger massuri etc. Va urez bafta in a ne ajuta cu respect echipa stylegame

    [PHP] Random readable password

    CYobY
    CYobY
    Administrator
    Administrator


    Mesaje : 197
    Data de inscriere : 04/10/2009
    Varsta : 30
    Localizare : VASLUI

    [PHP] Random readable password Empty [PHP] Random readable password

    Mesaj Scris de CYobY Sam Oct 24, 2009 6:25 pm

    Cod:
        function random_readable_pwd($length=10){

            // the wordlist from which the password
            // gets generated: (adjust them here:)
            $words = 'dog,cat,sheep,sun,sky,red,ball,happy,ice';
            $words .= 'green,blue,music,movies,radio,green,turbo';
            $words .= 'mouse,computer,paper,water,fire,storm,chicken';
            $words .= 'boot,freedom,white,nice,player,small,eyes';
            $words .= 'path,kid,box,black,flower,ping,pong,smile';
            $words .= 'coffee,colors,rainbow,plus,king,tv,ring';

            // explode by ",":
            $words = explode(',', $words);
            if (count($words) == 0){ die('Wordlist is empty!'); }

            mt_srand((double)microtime()*1000000);

            // while password is smaller than $length -> add
            // words:
            $pwd = '';
            while (strlen($pwd) <length> 2 and
            // reduce the password size to $length
            $num = mt_rand(1, 99);
            if ($length > 2){
                $pwd = substr($pwd,0,$length-strlen($num)).$num;
            } else {
                $pwd = substr($pwd, 0, $length);
            }

            return $pwd;

        }

      Data/ora curentă este: Dum Mai 19, 2024 1:57 pm