Difference between revisions of "Ns sha1"
Jump to navigation
Jump to search
(added additional links to alternative sha1 implementations (non-aolserver)) |
|||
Line 31: | Line 31: | ||
This function is provided by the [[nssha1]] module. | This function is provided by the [[nssha1]] module. | ||
− | Unfortunately, this implementation does not seem to be immediately compatible with other SHA1 implementations. | + | Unfortunately, this implementation does not seem to be immediately compatible with [http://www.xml-dev.com/blog/sha1.php other] SHA1 [http://www.movable-type.co.uk/scripts/SHA-1.html implementations]. |
Postgresql: | Postgresql: |
Revision as of 14:31, 3 December 2005
Function
ns_sha1 string
Description
Returns a 40-character, hex-encoded string containing the SHA1 hash of the first argument.
Usage
Example 1:
set sRawPassword "mypassword" set sPassword [ns_sha1 $sRawPassword] ns_adp_puts $sPassword # 04003622EB9D0F788CE7568C7EED23809534365A
Usually this function is used with a salt, as without a salt it is succeptible to dictionary-based attacks.
Example 2:
set sSalt "salty" set sRawPassword "mypassword" set sPassword [ns_sha1 ${sRawPassword}${sSalt}] # B48FB74597C11FC609DBE912992085EB07847FB6
This function is provided by the nssha1 module.
Unfortunately, this implementation does not seem to be immediately compatible with other SHA1 implementations.
Postgresql:
template1=> select encode(digest('mypassword','SHA1'),'hex'); encode ------------------------------------------ 91dfd9ddb4198affc5c194cd8ce6d338fde470e2 (1 row)
SEE ALSO