Skip to content

Instantly share code, notes, and snippets.

@caramelchocolate
Last active February 14, 2019 04:28
Show Gist options
  • Save caramelchocolate/04d73ae8258252f93c108b670ec85ec0 to your computer and use it in GitHub Desktop.
Save caramelchocolate/04d73ae8258252f93c108b670ec85ec0 to your computer and use it in GitHub Desktop.
hash
php main.php
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7
python main.py
ec824fb844e4df008219d4c1af2a7673eff8a762aac7acef5104e021ee39c498a9389620571cb9e77627ec6a03e8d72b5930abc65d2a7c3265676897aa46bbc7
<?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;
?>
# -*- 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