Admidio API
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Packages

  • com
    • tecnick
      • tcpdf
  • None
  • PHPMailer
    • easypeasyics
  • PHPWavUtils
  • Securimage
    • classes

Classes

  • AutoLogin
  • Component
  • ComponentUpdate
  • ConditionParser
  • Database
  • DateTimeExtended
  • Email
  • Folder
  • FormValidation
  • FunctionClass
  • Htaccess
  • HtmlDiv
  • HtmlElement
  • HtmlForm
  • HtmlFormBasic
  • HtmlFormInstallation
  • HtmlList
  • HtmlNavbar
  • HtmlPage
  • HtmlTable
  • HtmlTableBasic
  • Image
  • Inventory
  • InventoryFields
  • Language
  • LanguageData
  • ListConfiguration
  • Menu
  • Message
  • ModuleAnnouncements
  • ModuleDates
  • ModuleLists
  • ModuleMenu
  • ModuleMessages
  • Modules
  • ModuleWeblinks
  • MyFiles
  • Navigation
  • ntlm_sasl_client_class
  • Organization
  • Participants
  • PasswordHash
  • PasswordHashing
  • ProfileFields
  • RoleDependency
  • RolesRights
  • RSSfeed
  • Session
  • SystemMail
  • TableAccess
  • TableAnnouncement
  • TableCategory
  • TableDate
  • TableFile
  • TableFolder
  • TableGuestbook
  • TableGuestbookComment
  • TableInventory
  • TableInventoryField
  • TableLists
  • TableMembers
  • TableMessage
  • TablePhotos
  • TableRoles
  • TableRooms
  • TableText
  • TableUserField
  • TableUsers
  • TableWeblink
  • UploadHandlerDownload
  • UploadHandlerPhoto
  • User
  • UserRegistration

Exceptions

  • AdmException
  • WavFileException
  • WavFormatException

Functions

  • admFuncAutoload
  • admFuncGeneratePagination
  • admFuncGetBytesFromSize
  • admFuncGetDirectoryEntries
  • admFuncMaxUploadSize
  • admFuncProcessableImageSize
  • admFuncShowCreateChangeInfoById
  • admFuncShowCreateChangeInfoByName
  • admFuncVariableIsValid
  • admReadTemplateFile
  • admStrIsValidFileName
  • admStrStripTagsSpecial
  • admStrToLower
  • admStrToUpper
  • bzip2Version
  • checkDatabaseVersion
  • checkPhpVersion
  • EmailAttachment
  • FileSizeNiceDisplay
  • FormattedTimeRemaining
  • FunctionIsDisabled
  • getFormerRolesFromDatabase
  • getFutureRolesFromDatabase
  • getmicrotime
  • getRoleMemberships
  • getRolesFromDatabase
  • gzipVersion
  • hasRole
  • hl_attrval
  • hl_bal
  • hl_cmtcd
  • hl_ent
  • hl_prot
  • hl_regex
  • hl_spec
  • hl_tag
  • hl_tag2
  • hl_tidy
  • hl_version
  • htmLawed
  • HTMLFilter
  • isGroupLeader
  • isMember
  • kses
  • kses_hook
  • MySQLdumpVersion
  • OutputInformation
  • SafeExec
  • showNotice
  • strAddSlashesDeep
  • strNextLetter
  • strStripSlashesDeep
  • strStripTags
  • strValidCharacters
  • tln_body2div
  • tln_casenormalize
  • tln_deent
  • tln_defang
  • tln_findnxreg
  • tln_findnxstr
  • tln_fixatts
  • tln_fixstyle
  • tln_fixurl
  • tln_getnxtag
  • tln_sanitize
  • tln_skipspace
  • tln_tagprint
  • tln_unspace
  • version_compare_replacement
  • version_compare_replacement_sub

Class PasswordHashing

Copyright: 2004-2016 The Admidio Team
License: GNU General Public License v2.0 only **********************************************************************************************
Class:

PasswordHashing

This class provides static functions for different tasks for passwords and hashing It used the "password_compat" lib to provide forward compatibility with the password_* functions that ship with PHP 5.5 It used the "random_compat" lib to provide forward compatibility with the random_* functions that ship with PHP 7.0 It used the "phpass" lib to provide backward compatibility to the old password hashing way

Functions: hash() hash the given password with the given options verify() verify if the given password belongs to the given hash needsRehash() checks if the given hash is generated from the given options genRandomPassword() generate a cryptographically strong random password genRandomInt() generate a cryptographically strong random int passwordInfo() provides infos about the given password (length, number, lowerCase, upperCase, symbol) hashInfo() provides infos about the given hash (Algorithm & Options, PRIVATE/PORTABLE_HASH, MD5, UNKNOWN) costBenchmark() run a benchmark to get the best fitting cost value


Located at passwordhashing.php

Methods summary

public static string|false
# hash( string $password, string $algorithm = 'DEFAULT', array $options = array() )

Hash the given password with the given options. The default algorithm uses the password_* methods, otherwise the builtin helper for SHA-512 crypt hashes from the operating system. Minimum cost is 10.

Hash the given password with the given options. The default algorithm uses the password_* methods, otherwise the builtin helper for SHA-512 crypt hashes from the operating system. Minimum cost is 10.

Parameters

$password
The password string
$algorithm
The hash-algorithm method. Possible values are 'DEFAULT', 'BCRYPT' or 'SHA512'.
$options
The hash-options array

Returns

string|false
Returns the hashed password or false if an error occurs
public static boolean
# verify( string $password, string $hash )

Verify if the given password belongs to the given hash

Verify if the given password belongs to the given hash

Parameters

$password
The password string to check
$hash
The hash string to check

Returns

boolean
Returns true if the password belongs to the hash and false if not
public static boolean
# needsRehash( string $hash, string $algorithm = 'DEFAULT', array $options = array() )

Checks if the given hash is generated from the given options. The default algorithm uses the password_* methods, otherwise the builtin helper for SHA-512 crypt hashes from the operating system.

Checks if the given hash is generated from the given options. The default algorithm uses the password_* methods, otherwise the builtin helper for SHA-512 crypt hashes from the operating system.

Parameters

$hash
The hash string that should checked
$algorithm
The hash-algorithm the hash should match to
$options
The hash-options the hash should match to

Returns

boolean
Returns false if the hash match the given options and false if not
public static string
# genRandomPassword( integer $length = 12, string $charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' )

Generate a cryptographically strong random password

Generate a cryptographically strong random password

Parameters

$length
The length of the generated password (default = 12)
$charset
A string of all possible characters to choose from (default = [0-9a-zA-z])

Returns

string
Returns a cryptographically strong random password string

Throws

AdmException
SYS_GEN_RANDOM_TWO_DISTINCT_CHARS, SYS_GEN_RANDOM_ERROR, SYS_GEN_RANDOM_FAIL

Link

https://paragonie.com/b/JvICXzh_jhLyt4y3
public static integer
# genRandomInt( integer $min, integer $max )

Generate a cryptographically strong random integer

Generate a cryptographically strong random integer

Parameters

$min
The min of the range (inclusive)
$max
The max of the range (inclusive)

Returns

integer
Returns a cryptographically strong random integer

Throws

AdmException
SYS_GEN_RANDOM_ERROR, SYS_GEN_RANDOM_FAIL
public static array<string,int|bool>
# passwordInfo( string $password )

Provides infos about the given password (length, number, lowerCase, upperCase, symbol)

Provides infos about the given password (length, number, lowerCase, upperCase, symbol)

Parameters

$password
The password you want the get infos about

Returns

array<string,int|bool>
Returns an array with infos about the given password
public static array|string
# hashInfo( string $hash )

Provides infos about the given hash (Algorithm & Options, PRIVATE/PORTABLE_HASH, MD5, UNKNOWN)

Provides infos about the given hash (Algorithm & Options, PRIVATE/PORTABLE_HASH, MD5, UNKNOWN)

Parameters

$hash
The hash you want the get infos about

Returns

array|string
Returns an array or string with infos about the given hash
public static array
# costBenchmark( float $maxTime = 0.5, string $password = 'password', string $algorithm = 'DEFAULT', array $options = array('cost' => 12) )

Run a benchmark to get the best fitting cost value. The cost value can vary from 4 to 31.

Run a benchmark to get the best fitting cost value. The cost value can vary from 4 to 31.

Parameters

$maxTime
The maximum time the hashing process should take in seconds
$password
The password to test
$algorithm
The algorithm to test
$options
The options to test

Returns

array
Returns an array with the maximum tested cost with the required time
Admidio API API documentation generated by ApiGen