I need the actual algorithm used by Oracle's DBMS_UTILITY.get_hash_value
function. I need to be able to generate this information without access to an Oracle database.
Asked
Active
Viewed 1,591 times
1

Dan Forbes
- 2,734
- 3
- 30
- 60
-
1When you're talking about hashing functions, you need to specify for what purpose - e.g. is it for detecting duplicates, spreading data evenly, or is it for a cryptographic application? – Jeffrey Kemp Aug 14 '13 at 05:04
-
1I appreciate the help, but I don't really see the relevance of *why*...not to mention the fact that I think that, in this case, it would violate my NDA to disclose that fact. I'm being asked to develop a tool that needs to replicate Oracle's hash function...isn't that reason enough? – Dan Forbes Aug 14 '13 at 22:24
-
You don't need to violate your NDA, you just need to be more specific than just "I want a hash function algorithm". That's like saying "I want the sorting algorithm" assuming there's only one - i.e. not specifying whether you want an algorithm that sorts faster, uses less memory, or performs fewer exchanges. – Jeffrey Kemp Aug 15 '13 at 02:24
-
1I don't really think that's a fair representation of what I asked, though. I'm asking for a very specific algorithm - the DBMS_UTILITY.GET_HASH_VALUE algorithm. I know I'm not the only person who would be interested in this (see, https://forums.oracle.com/thread/1528240). I understand it's important to be clear in your questions, but I don't see where I failed to do that. – Dan Forbes Aug 15 '13 at 03:49
-
Ok, fair enough. What you're asking for is a duplication of the algorithm in Java so that you can avoid a database call. I'm guessing you have existing code that calls `DBMS_UTILITY.get_hash_value`, and you want to implement it in Java so that your code still works effectively the same. Unfortunately the Oracle documentation doesn't specify the algorithm used, so I'm not sure that you're going to get an answer except by someone who can somehow reverse engineer Oracle's implementation. – Jeffrey Kemp Aug 15 '13 at 03:53
-
1Voting to reopen based on clarified requirements. – Jeffrey Kemp Aug 15 '13 at 03:56
-
1The actual situation is that, I am told, I do not have access to an Oracle database, but that I need to be able get the mapping of String -> DBMS_UTILITY.GET_HASH_VALUE. – Dan Forbes Aug 15 '13 at 03:56
-
That makes sense. I'm not sure if there's going to be an answer, but if someone does know it, it'll be interesting. – Jeffrey Kemp Aug 15 '13 at 04:00
1 Answers
3
Oracle doesn't detail the implementation of the hash, and Tom Kyte has indicated that the implementation can change release to release. If you are looking for a hash function you can use in Java and Oracle, you can do SHA1 (and other) hashes using sys.dbms_crypto.hash
in oracle, and MessageDigest.getInstance("SHA-1")
(for details see this question - Java String to SHA1).
If you need to use the same algorithim as Oracle's GET_HASH_VALUE, perhaps contacting Oracle support may help...
-
it's a hash function, of course it's going to get collisions! (note -how likely this is depends on what hash size you choose) – Jeffrey Kemp Aug 14 '13 at 05:02
-
1Yeah, but no one has yet found two messages that give a collision on an SHA-1 hash. For purposes of identifying a unique record or differences between two records based on typical database data, SHA1 should suffice. There's always SHA-256. http://stackoverflow.com/questions/3475648/sha1-collision-demo-example – N West Aug 14 '13 at 13:56
-
You said "people have found collisions often with it" as if that indicated an inherant fault in its implementation. I felt that was a bit unfair. Also, you are making the assumption that the OP needs a hash that identifies unique records/differences between two records - an assumption which, I believe, is unwarranted given the lack of detail in the question. Note, however, I'm not downvoting your answer. – Jeffrey Kemp Aug 15 '13 at 02:27
-
I don't need DBMS_UTILITY.GET_HASH_VALUE because it is a good hash function, I need it because it is the *exact* hash function that I need. It's pretty simple. – Dan Forbes Aug 15 '13 at 04:01
-
1@Dan Forbes, Per Tom Kyte, the implementation detail of that function is not available, and *may change* between versions of the Oracle database. http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:95412348059 `We change the hash algorithm from release to release (it has happened at least once in the past and could happen again). You need to look at alternative ways.` – N West Aug 15 '13 at 13:20
-
1@JeffreyKemp Agreed. I did assume that the need for a hash was in related to the records - I updated my answer to be a more general reason not to use it. – N West Aug 15 '13 at 13:22