PySide6.QtCore.QHashSeed¶
- class QHashSeed¶
Added in version 6.2.
Synopsis¶
Methods¶
def
__init__()
Static functions¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
The
QHashSeedclass is used to convey theQHashseed. This is used internally byQHashand provides three static member functions to allow users to obtain the hash and to reset it.QHashand theqHash()functions implement what is called as “salted hash”. The intent is that different applications and different instances of the same application will produce different hashing values for the same input, thus causing the ordering of elements inQHashto be unpredictable by external observers. This improves the applications’ resilience against attacks that attempt to force hashing tables into degenerate mode.Most applications will not need to deal directly with the hash seed, as
QHashwill do so when needed. However, applications may wish to use this for their own purposes in the same way asQHashdoes: as an application-global random value (but seeQRandomGeneratortoo). Note that the global hash seed may change during the application’s lifetime, if theresetRandomGlobalSeed()function is called. Users of the global hash need to store the value they are using and not rely on getting it again.This class also implements functionality to set the hash seed to a deterministic value, which the
qHash()functions will take to mean that they should use a fixed hashing function on their data too. This functionality is only meant to be used in debugging applications. This behavior can also be controlled by setting theQT_HASH_SEEDenvironment variable to the value zero (any other value is ignored).See also
QHashQRandomGenerator- __init__([d=0])¶
- Parameters:
d – int
Constructs a new
QHashSeedobject usingdataas the seed.Returns the current global
QHashseed. The value returned by this function will be zero ifsetDeterministicGlobalSeed()has been called or if theQT_HASH_SEEDenvironment variable is set to zero.- static resetRandomGlobalSeed()¶
Reseeds the Qt hashing seed to a new, random value. Calling this function is not necessary, but long-running applications may want to do so after a long period of time in which information about its hash may have been exposed to potential attackers.
If the environment variable
QT_HASH_SEEDis set to zero, calling this function will result in a no-op.Qt never calls this function during the execution of the application, but unless the
QT_HASH_SEEDvariable is set to 0, the hash seed returned byglobalSeed()will be a random value as if this function had been called.- static setDeterministicGlobalSeed()¶
Forces the Qt hash seed to a deterministic value (zero) and asks the
qHash()functions to use a pre-determined hashing function. This mode is only useful for debugging and should not be used in production code.Regular operation can be restored by calling
resetRandomGlobalSeed().