Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8210331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:02:21+00:00 2026-06-07T10:02:21+00:00

I have a PHP application that has passwords stored in the database as the

  • 0

I have a PHP application that has passwords stored in the database as the output of sha1($password), which is apparently the hex representation of the binary SHA1 hash. (as I understand it)

I would like to convert that to a format that is compatible for Apache .htpassword files, which needs to be the base64 encoded binary value or the output of base64_encode(sha1($password, true)).

I found this thread: Convert base64'd SHA1 hashes to Hex hashes … which is doing the opposite of what I need to do, and it works great. I tried to change the ordering of the commands and use hex2bin instead of bin2hex, but that doesn’t work:

Fatal error: Call to undefined function hex2bin() in php shell code on line 1

Apparently that is not available until PHP 5.4, and this server is still on 5.3.x
http://php.net/manual/en/function.hex2bin.php

Here is the real problem. I actually need it to convert in PERL, preferably only using standard built-in modules to keep everything simple. I am not sure why they are using perl for this step, but I am trying to edit one very small part of a larger application and don’t want to change the whole thing yet 🙂

To be clear, I am not trying to convert hex numbers to binary numbers. This is a hex representation of a binary value, stored in a perl “string” 🙂

Thanks in advance,
Tommy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:02:23+00:00Added an answer on June 7, 2026 at 10:02 am

    You explain so much but still leave me unsure as to what you want :/

    If what you want is to convert from a hex string to a blob to base64 string, which is what you say you want in the top paragraph of your question,

    use MIME::Base64;
    my $bin = pack "H*", $hex_str;
    my $encoded = encode_base64($bin);
    

    which exactly matches what you want: base64_encode(sha1($password, true))

    Ignore my previous answers and edits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP application that has grown in size. The database used to
I have Mamp Pro and have a PHP application that sends an email password
I have a php application that has about 50-55 code files. The file that
I have a php application that uses the google feed api to get the
I have a PHP application that I have been having some problems with, some
I have a php application that is installed on several servers and all of
I have a PHP application that sends email using the pear Mail function. Unfortunately
I have a PHP application that is built around the MVC architecture without any
I have a php web application that uses big cookies to store a lot
We have a PHP/MYSQL application that collects user input, including special characters like ø,ü,ñ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.