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

  • SEARCH
  • Home
  • 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 7558957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:30:34+00:00 2026-05-30T12:30:34+00:00

I am developing website and I am doing my best to ensure that I

  • 0

I am developing website and I am doing my best to ensure that I have a good security system. I am going to tell you what I have done and I have also another question about this system.

1) I am using sha512 method to hash password.salt and save it in database

2) my salt is generating randomly and every salt is unique, I am using this methods (developed in Yii framework)

class Random extends CApplicationComponent
{
    public static function intRandom($min, $max) 
    {
        $bits = '';

        $diff = $max-$min;
        $bytes = ceil($diff/256);


        $fp = @fopen('/dev/urandom','rb');
        if ($fp !== FALSE) {
            $bits .= @fread($fp,$bytes);
            @fclose($fp);
        }
        $bitlength = strlen($bits);
        for ($i = 0; $i < $bitlength; $i++) {
            $int =  1+(ord($bits[$i]) % (($max-$min)+1));
        }
        return $int;
    }

    public static function strRandom($length) {
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-+=|]}[{;:?.,></";   

        $size = strlen( $chars );
        for( $i = 0; $i < $length; $i++ ) {
            $str .= $chars[ self::intRandom(0, strlen($chars)-1) ];
        }

        return $str;
    }
}

3) after user loges in I am generating new salt and hashing password.new_salt (of course every salt must be unique)

        while ($record2 !== null){
            $salt = Random::strRandom(32);
            $record2 = User::model()->findByAttributes(array('salt'=>$salt));
        }
        $record->salt = $salt;
        $record->password = hash('sha512', $this->password.$salt);
        $record->save;

4) now it is time to save salt in database, and I am using Rijndael two way crypting method for it. mc_key is located in php file and every month I am replacing it.

function mc_encrypt($encrypt, $mc_key) {
    $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
    $passcrypt = trim(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mc_key, trim($encrypt), MCRYPT_MODE_ECB, $iv));
    $encode = base64_encode($passcrypt);
    return $encode;
}

// Decrypt Function
function mc_decrypt($decrypt, $mc_key) {
    $decoded = base64_decode($decrypt);
    $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
    $decrypted = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $mc_key, trim($decoded), MCRYPT_MODE_ECB, $iv));
    return $decrypted;
}

So, What do you think? Is it enough or should I use something more?

I think, I made nightmare for hacker, or I am just another stupid programmer who is trying to create another bicycle.

  • 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-05-30T12:30:36+00:00Added an answer on May 30, 2026 at 12:30 pm

    One issue is that plain SHA512 is fast. You should use a slower method, such as bcrypt


    And intRandom sucks. If I understand it correctly

    1. it fails silently when /dev/urandom is absent, instead of dying loudly.
    2. The logic for $max-$min>=256 looks completely broken.
    3. $min != 1 is broken
    4. Its return values are not uniform
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a website that connects to a users MSSQL database to collect
I'm considering developing a website similar to stackoverflow, but the answers may also consist
I am developing a website that relies much on XML data. The web site
I'm developing a website (in Django) that uses OpenID to authenticate users. As I'm
I am developing a website that relies on pulling the geolocation data of a
I have a general question about DB synchronisation. So, I'm developing a website locally
Developing rails has become lots of fun over the year that I've done it,
I have a small problem developing/optimizing a web page. I know it is good
I'm developing a website (using asp.net-mvc) with a SqlServer 2005 database. I have numerous
I'm developing a complex website that heavily leverages jQuery and a number of scripts.

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.