将base64的SHA SHAhes转换为Hex哈希 [英] Convert base64'd SHA1 hashes to Hex hashes
问题描述
我有一个使用
$ b
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');
由于这些是我们的邮件系统使用的密码,我们想要转换为另一个邮件系统(但要求它是40字符的十六进制哈希:(
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!)
请注意,我提到数据是在mySQL中 - 这是无关紧要的 - 我知道如何得到的数据,只是不转换它。
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 it.
散列是相同的 - 我只是试图转换信息的方式打包(我认为这只是需要)
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);
这篇关于将base64的SHA SHAhes转换为Hex哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!