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 9302535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:16:44+00:00 2026-06-18T23:16:44+00:00

For authentification with Dovecot, I use SSHA256 hashes but I have no clue how

  • 0

For authentification with Dovecot, I use SSHA256 hashes but I have no clue how to validate a given password against the existing hash. The following PHP functions (found them in the web) are used to create the SSHA256 hash:

function ssha256($pw) {
        $salt = make_salt();
        return "{SSHA256}" . base64_encode( hash('sha256', $pw . $salt, true ) . $salt );
}

function make_salt() {
        $len   = 4;
        $bytes = array();
        for ($i = 0; $i < $len; $i++ ) {
                $bytes[] = rand(1,255);
        }
        $salt_str = '';
        foreach ($bytes as $b) {
                $salt_str .= pack('C', $b);
        }
        return $salt_str;
}

Example output: {SSHA256}lGq49JTKmBC49AUrk7wLyQVmeZ7cGl/V13A9QbY4RVKchckL

Do I have to extract the salt, but how?
I totally lost the way for solving the problem, has anyone a hint for this?

Thanks to everyone for helping!

Oh and sorry, I have to use SSHA256, because Dovecot 1.2.15 supports only those schemes:
CRYPT MD5 MD5-CRYPT SHA SHA1 SHA256 SMD5 SSHA SSHA256 PLAIN CLEARTEXT CRAM-MD5 HMAC-MD5 DIGEST-MD5 PLAIN-MD4 PLAIN-MD5 LDAP-MD5 LANMAN NTLM OTP SKEY RPA

  • 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-18T23:16:46+00:00Added an answer on June 18, 2026 at 11:16 pm

    You should not be using the SHA family for password hashing. They are fast and designed for hashing files at speed. You need pashword hashing to be expensive. Use bcrypt, PHPass or just use this class, which I rolled myself (but not until you learn to pick holes in it):

    class PassHash {
        public static function rand_str($length) {
            $total = $length % 2;
            $output = "";
            if ($total !== 0) {
                $count = floor($length / 2);
                $output .= ".";
            } else $count = $length / 2;
    
            $bytes = openssl_random_pseudo_bytes($count);
            $output .= bin2hex($bytes);
    
            // warning: prepending with a dot if the length is odd.
            // this can be very dangerous. no clue why you'd want your
            // bcrypt salt to do this, but /shrug
    
            return $output;
        }
        // 2y is an exploit fix, and an improvement over 2a. Only available in 5.4.0+
        public static function hash($input) {
            return crypt($input, "$2y$13$" . self::rand_str(22));
    
        }
    
        // legacy support, add exception handling and fall back to <= 5.3.0
        public static function hash_weak($input) {
            return crypt($input, "$2a$13$" . self::rand_str(22));
        }
    
        public static function compare($input, $hash) {
            return (crypt($input, $hash) === $hash);
        }
    }
    

    You have to hash the plaintext given and compare that hash against one you have stored. The salts are stored in the hashes, and should be random. If you like, add a pepper. You should also make the workrate variable, so that you can change the workrate at any moment when needed and still have your system work.


    If, like you say, you have no way of implementing this, you can unpack the hash as follows:

    function unpack_hash($hash) {
            $hash = base64_decode($hash);
            $split = str_split($hash, 64);
            return array("salt" => $split[1], "hash" => $split[0]);
    

    This is because SHA256 is 256 bits, or 64 hex characters. You can just always assume the first 64 chars are the hash

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

Sidebar

Related Questions

I'm creating an authentification file with php and mysql, but I have this mistake
I use the authentification system provided by FOSUser bundle Everything was doing fine but
I have a small web application that use jdbcRealm for authentification/authorisation. The authorisation works
I try to use the facebook authentification in my app but I'm not able
I'm building an Authentification library that's going to have around 45+ methods for dealing
I have a facebook app that I authenticate using a general-purpose authentification. Like this:
Im not sure about what authentification method I should use for my webservice. I've
I'm using devise for authentification, so I have a current_user in every controller. My
I'm following this excellent article to setup the authentification part of my rails (3.2)
I'm using rails devise gem for users authentification, but now for my shop i

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.