Oracle Hash MD5 解密
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31451621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Hash MD5 decryption
提问by ZerOne
I use this method to encrypt my string:
我使用这种方法来加密我的字符串:
RETURN RAWTOHEX(DBMS_CRYPTO.HASH(SRC=>to_hash, TYP=>dbms_crypto.HASH_MD5));
Now I have the encrypted MD5 string like:
现在我有加密的 MD5 字符串,如:
F267E16E70C2528280A487D5D13617A6
F267E16E70C2528280A487D5D13617A6
Is there a way to decrypt this code to get the start-string again?
有没有办法解密此代码以再次获取开始字符串?
回答by krause
MD5 is a hashing algorithm, not really intended for encryption or decryption. So, no, there is no way to get the start-string again. Actually, given a hash, there would be many potential start-strings it could come from.
MD5 是一种散列算法,并非真正用于加密或解密。所以,不,没有办法再次获得开始字符串。实际上,给定一个散列,它可能来自许多潜在的起始字符串。
回答by Marmite Bomber
The hash function is not isomorphic, i.e. it is not possible in general case to invert the function and get the unique original value. This is is something very different to beeing "safely decoded". If there is additional knowledge e.g. about the lenght of the string, it is very easy (with some CPU power) to get all candidate strings (i.e. the strings that map to the target hash value.
散列函数不是同构的,即在一般情况下不可能反转函数并获得唯一的原始值。这与蜜蜂“安全解码”非常不同。如果有额外的知识,例如关于字符串的长度,很容易(使用一些 CPU 能力)获得所有候选字符串(即映射到目标哈希值的字符串)。
So this is probably not the optimal way to decode password etc.
所以这可能不是解码密码等的最佳方式。
Simple example for strings with length three:
长度为三的字符串的简单示例:
select (DBMS_CRYPTO.HASH( RAWTOHEX('Scr'), 2 /* dbms_crypto.HASH_MD5*/ )) from DUAL;
93656D76795528C600E7BF7A17B09C8E
with chr as (
select chr(ascii('A') -1 + rownum) chr from dual connect by level <= 26
union all
select chr(ascii('a') -1 + rownum) chr from dual connect by level <= 26
union all
select chr(ascii('0') -1 + rownum) chr from dual connect by level <= 10
),
chr2 as (
select a.chr||b.chr||c.chr str
from chr a, chr b, chr c
)
select * from chr2
where DBMS_CRYPTO.HASH( RAWTOHEX(str), 2 /* dbms_crypto.HASH_MD5*/ )
= '93656D76795528C600E7BF7A17B09C8E'
;
Scr
回答by Sentinel
Hashing algorithms are one way functions. As such there is no feasible way to reverse the calculations involved and arrive at the original input value. Further hashing algorithms operate on input strings of arbitrary length but have a fixed width output, in the case of the MD5 algorithm it outputs a 16 byte hash value that could represent an input value of 16 bytes or 16,000 bytes or more.
散列算法是单向函数。因此,没有可行的方法来反转所涉及的计算并得出原始输入值。进一步的哈希算法对任意长度的输入字符串进行操作,但具有固定宽度的输出,在 MD5 算法的情况下,它输出一个 16 字节的哈希值,可以表示 16 字节或 16,000 字节或更多的输入值。
So while you can't reverse the algorithm to retrieve the original input, you can compute the hash values of potential candidate inputs to (hopefully) find one that matches your existing hash value. Some knowledge of the original input string would be helpful in reducing the problem space of this sort of brute force attack.
因此,虽然您无法反转算法来检索原始输入,但您可以计算潜在候选输入的哈希值,以(希望)找到与您现有的哈希值匹配的输入。原始输入字符串的一些知识将有助于减少这种蛮力攻击的问题空间。