[PHP] CRYPT_BLOWFISH werkt niet

Pagina: 1
Acties:
  • 460 views

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Beatboxx
  • Registratie: April 2010
  • Laatst online: 26-10-2022

Beatboxx

Certified n00b

Topicstarter
Ik wil wachtwoorden met crypt_blowfish encrypten maar op een of andere manier krijg ik altijd een error. Mijn code is gewoon:

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function generate.salt($length=22){  
    $key = '';  
    $pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";  
    for($i=0;$i<$length;$i++){  
        $key .= $pattern{rand(0,61)};  
        }  
    return $key;  
}  
$pass = 'blablabla';
$salt = generate.salt(); 
$hash = CRYPT_BLOWFISH($pass, $salt);
?>


Uitvoeren geeft:
Fatal error: Call to undefined function CRYPT_BLOWFISH() in /directory/to/thefile on line xx
phpinfo() zegt dat ik PHP 5.3.8 draai. CRYPT_BLOWFISH zit vanaf 5.3.8 in php, dus het zou toch gewoon moeten werken? Met kleine letters werkt het ook niet....

Acties:
  • 0 Henk 'm!

  • GlowMouse
  • Registratie: November 2002
  • Niet online
Beatboxx schreef op woensdag 26 oktober 2011 @ 15:07:
CRYPT_BLOWFISH zit vanaf 5.3.8 in php
waar staat dat het een functie is?

Acties:
  • 0 Henk 'm!

  • Beatboxx
  • Registratie: April 2010
  • Laatst online: 26-10-2022

Beatboxx

Certified n00b

Topicstarter

Acties:
  • 0 Henk 'm!

  • -DarkShadow-
  • Registratie: December 2001
  • Niet online
CRYPT_BLOWFISH is een constante, geen functie.

Gebruik dit:
PHP:
1
2
3
if (CRYPT_BLOWFISH == 1) {
    echo 'Blowfish:     ' . crypt('rasmuslerdorf', '$2a$07$usesomesillystringforsalt$') . "\n";
}

[ Voor 63% gewijzigd door -DarkShadow- op 26-10-2011 15:14 ]

Specialist in:
Soldeerstations
Oscilloscoop


Acties:
  • 0 Henk 'm!

  • GateKeaper
  • Registratie: April 2004
  • Laatst online: 26-05 09:50

GateKeaper

#1 Procastinator

CRYPT_BLOWFISH - Blowfish hashing with a salt as follows: "$2a$", a two digit cost parameter, "$", and 22 digits from the alphabet "./0-9A-Za-z". Using characters outside of this range in the salt will cause crypt() to return a zero-length string. The two digit cost parameter is the base-2 logarithm of the iteration count for the underlying Blowfish-based hashing algorithmeter and must be in range 04-31, values outside this range will cause crypt() to fail.
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/** 
 * Example #3 Using crypt() with different hash types
 */


if (CRYPT_STD_DES == 1) {
    echo 'Standard DES: ' . crypt('rasmuslerdorf', 'rl') . "\n";
}

if (CRYPT_EXT_DES == 1) {
    echo 'Extended DES: ' . crypt('rasmuslerdorf', '_J9..rasm') . "\n";
}

if (CRYPT_MD5 == 1) {
    echo 'MD5:          ' . crypt('rasmuslerdorf', '$1$rasmusle$') . "\n";
}

if (CRYPT_BLOWFISH == 1) {
    echo 'Blowfish:     ' . crypt('rasmuslerdorf', '$2a$07$usesomesillystringforsalt$') . "\n";
}

if (CRYPT_SHA256 == 1) {
    echo 'SHA-256:      ' . crypt('rasmuslerdorf', '$5$rounds=5000$usesomesillystringforsalt$') . "\n";
}

if (CRYPT_SHA512 == 1) {
    echo 'SHA-512:      ' . crypt('rasmuslerdorf', '$6$rounds=5000$usesomesillystringforsalt$') . "\n";
}
?> 

Acties:
  • 0 Henk 'm!

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 01-06 22:57

Creepy

Tactical Espionage Splatterer

Oftewel: volgende keer gewoon zelf even de manual lezen die je linkt. Daar staan kant en klare voorbeelden ;) Doe nu de volgende keer aub eens echt zelf wat moeite. Dit staat letterlijk 1 op 1 in de manual (die je zelf linkt) dus dit had je echt zelf moeten kunnen regelen. Het is hier geen helpdesk om ff snel code te scoren, maar zo gebruik je het forum nu al wel een paar keer.

[ Voor 40% gewijzigd door Creepy op 26-10-2011 16:19 ]

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1

Dit topic is gesloten.