How to access sha1() in my code?

Discussion in 'PHP' started by phummon, Jul 21, 2010.

  1. #1
    Hi everyone,

    Full disclosure: I'm an experienced programming who is relatively new to PHP. Unfortunately, I'm also in a bit of a jam. In short, my boss gave me some PHP code and said, "You have to get this working by Friday." I don't have the luxury to do the proper tutorials, otherwise I wouldn't be rushing to this forum in a bit of a panic.

    Here's the problem. The code I'm working with has this line:

    $variable1 = sha1("12345678".$user.$passwd);
    PHP:
    When I execute, the compiler gives me this result...

    <br>
    <b>Fatal error</b>:  Call to undefined function:  sha1() in <b>/export/qhome/dude1/script1.php</b> on line <b>38</b><br>
    Code (markup):
    ...which I'm interpreting to mean "I don't know what this sha1() command is!" If this were C++ code (my home turf), I'd just "man sha," figure out which library I need to add, and then pop in the needed "#include ______" statement at the top of my code. That didn't work for in this case.

    Does anyone have any insight?

    Many, many thanks in advance!
    -P
     
    phummon, Jul 21, 2010 IP
  2. bencummins

    bencummins Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What version of php do you have? was included in 4.3 onwards
     
    bencummins, Jul 21, 2010 IP
  3. phummon

    phummon Active Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    Yeah, I just found out I'm on PHP Version 4.0.3pl1, which neatly explains the problem. Man, is my face red...!

    Many thanks!
    -P
     
    phummon, Jul 21, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hash('sha1',$variable);
     
    krsix, Jul 21, 2010 IP