开发者

Convert base64'd SHA1 hashes to Hex hashes

开发者 https://www.devze.com 2022-12-31 22:29 出处:网络
I have a list of passwords in mySQL that are generated using $hash = \'{SHA}\' . base64_encode(sha1(\'some string here\', true));

I have a list of passwords in mySQL that are generated using

$hash = '{SHA}' . base64_encode(sha1('some string here', true));

I need to convert these into what would be the equivalent of

$hash = sha1('some string here');

As these are password that our mail system uses, and we want to convert to another mail system (but requires that it be the 40 char hex hash :(

How would I convert from one format to the other (I'm pretty sure I've done this before, but the other way, though I can't find the code!)

As a note, I mentioned that the data is in mySQL - this is irrelevant - I know how to get the data, just not to convert i开发者_运维知识库t.

The hash is the same - I am only trying to convert the way the information is packed (I think this just needs to be converted from base64 to base16, but that's just a guess!)


$binary = base64_decode(substr($hash, 5));
$hex = bin2hex($binary);


Well base64_decode() can be found in the base64_encode manual entry.
And I am sure they have a way to convert raw format in the sha1 manual entry comments, if it's too hard for you to write it yourself

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号