Posts

Showing posts with the label static

PHP password hash with salt

It is more secure to stora a password hashed with added static (or even dynamic salt). To achieve static salt in password just append a string when calculating a hash. Example below shows dynamic salt, most secure: function getHash( $pass , $login ) { $salt = substr( md5( $login ) , 0 , 10 ); return hash( 'sha256' , $pass . 'ThEStAtIcSaLe' . $salt ); } Remeber to use same function when checking user credentials.It will be also more secure to use slower hashing/crypting function

Call superclass method in object oriented PHP application

You can call parent methods using :: operator, as in example below: parent::init( 'aaa' ); This situation works also, when dealing with static methods.

Organize your global functions to static methods - alternative to structural/procedural programming

If you are not into Object Oriented Programming, and include files and functions everywhere, you can get lost in your own function names. The good alternative is to group your functions into classes with static methods: class UserModule { public static function getUserId() { ... } public static function removeUser( $id ) { ... } } UserModule::removeUser( 11 );