summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-01-26 13:38:20 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-01-26 13:38:20 +0100
commitdfbe4adfd080433f91409f028935b9f9879fceca (patch)
treebd2579c92d5561caee8f194e0f6f00fab74366da /inc
parent925ad1487c71b97ed6cdb2e339a8d84abd199fef (diff)
downloadrpg-dfbe4adfd080433f91409f028935b9f9879fceca.tar.gz
rpg-dfbe4adfd080433f91409f028935b9f9879fceca.tar.bz2
added SHA512 hashing method FS#2663
Diffstat (limited to 'inc')
-rw-r--r--inc/PassHash.class.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php
index 15ea8cbcf..080fb4778 100644
--- a/inc/PassHash.class.php
+++ b/inc/PassHash.class.php
@@ -61,6 +61,9 @@ class PassHash {
} elseif(preg_match('/^:B:(.+?):.{32}$/', $hash, $m)) {
$method = 'mediawiki';
$salt = $m[1];
+ } elseif(preg_match('/^\$6\$(.+?)\$/', $hash, $m)) {
+ $method = 'sha512';
+ $salt = $m[1];
} elseif($len == 32) {
$method = 'md5';
} elseif($len == 40) {
@@ -458,6 +461,25 @@ class PassHash {
}
/**
+ * Password hashing method SHA512
+ *
+ * This is only supported on PHP 5.3.2 or higher and will throw an exception if
+ * the needed crypt support is not available
+ *
+ * @param string $clear The clear text to hash
+ * @param string $salt The salt to use, null for random
+ * @return string Hashed password
+ * @throws Exception
+ */
+ public function hash_sha512($clear, $salt = null) {
+ if(!defined('CRYPT_SHA512') || CRYPT_SHA512 != 1) {
+ throw new Exception('This PHP installation has no SHA512 support');
+ }
+ $this->init_salt($salt, 8, false);
+ return crypt($clear, '$6$'.$salt.'$');
+ }
+
+ /**
* Password hashing method 'mediawiki'
*
* Uses salted MD5, this is referred to as Method B in MediaWiki docs. Unsalted md5