Last active
February 14, 2019 04:28
-
-
Save caramelchocolate/04d73ae8258252f93c108b670ec85ec0 to your computer and use it in GitHub Desktop.
hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php main.php | |
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7 | |
python main.py | |
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_hash ($password, $salt, $try_length=1) { | |
$hashed = ''; | |
$try_length = max($try_length, 1); | |
for ($i=0; $i<$try_length; $i++) { | |
$hashed .= hash('sha256', $hashed . $password . $salt, true); | |
} | |
return $hashed; | |
} | |
$b = get_hash("test", "test123456", 2); | |
echo bin2hex($b) . PHP_EOL; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import hashlib | |
def get_hash (password, salt, try_length=1): | |
hashed = b'' | |
try_length = max(try_length, 1) | |
for i in range(try_length): | |
tmpstr = hashed + password.encode('utf-8') + salt.encode('utf-8') | |
hashed += hashlib.sha256(tmpstr).digest() | |
return hashed | |
if __name__ == '__main__': | |
b = get_hash("test", "test123456", 2) | |
print(b.hex()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment