ORA_HASH alternative in Snowflake - oracle

I am trying to find the alternative to Ora_hash in Snowflake. My intent is to find an alternate in SNowflake which generates same HASH value for a string which ORA_HASH generates.
I tried using HASH, MD5, SHA1, SHA2 in Snowflake but none of them generates the same value as ORA_HASH.
Is there any other function which might match ORA_HASH or is there any other way?

Oracle's ORA_HASH is a relatively light hashing algorithm. However it is proprietary, so the details of the implementation are not published, as far as I know. However, being relatively lightweight, it might be possible to reverse-engineer it, and write your own. See the following answer for some pointers if you want to do that:
What is the algorithm used by the ORA_HASH function?

Related

Why even have hash tables?

Hash tables allow mapping keys to values by using a hashing function. Here the hashing function actually computes the index of the key mapped to a specific value. But I just can't get my head around why we even use hash tables it in the first place? Why do you need a hash table? Are maps/dictionaries not good enough? Why not declare a dictionary ({'key1': 'value1'} in Python) and use it in the places where a hash table is required? I read a lot about it and still don't get it. Can you help me understand this?
why do you need a hashtable, is the map/dictionary not good
This is like asking why you need an automotive engine, isn't a car good enough? An engine is how a car works; you just don't see the engine when you are driving the car. But if you are learning to become an automotive engineer, then you should learn how engines work and how to design, build and maintain them.
Likewise, a hash table is how a dictionary works, you just don't see the hash table if you are writing code that uses a dictionary. But if you are learning to become a computer scientist, then you should learn how hash tables and other data structures work, and how to design, build and maintain them.

Vigenere Attack Identification and Matching Algorithm

I have been trying to detect a block of data encrypted with the Vigenere algorithm for a long time..I want to determine which encryption algorithm the data I have is encrypted.I don't want to reach the original version of the data.
In the first case, since I have the original version of the data, I can understand that it is encrypted with a little comparison, but as I said, I am having trouble at the point of which cryptological function is used.
Only the function in my hand (assuming that I have the data in an unencrypted state) should be able to say that it is encrypted with the Vigenere algorithm.
What kind of method should I follow here, what should I do? I am waiting for your help and ideas. Thank you very much in advance.
**(I looked at the Kasiski method, but it works to find the key value of the encryption algorithm and to decrypt it.)

What are the performance consequences of encryption in SQL Server 2008?

If you had a table that had 100,000,000 email addresses (example) and you want to store them securely but you don't want to take a huge hit with performance when you retrieve them, how would you go about storing them?
Encryption algorithms are designed to be fast. If you have decided that encrypting your data is important (and personal information such as email address is important as #Marc B pointed out) then the question becomes "which algorithm has the right performance for my use case?"
I'd suggest you look at how much throughput you are expecting and test it. Use an industry standard algorithm and see if it meets your needs. Whatever you do, don't roll your own encryption. Crypto is hard to get right so trust the experts.
I'd suggest you start with AES/CBC/PKCS5. Store the ciphertext as a blob in the database. Key storage is always tricky and has been discussed on StackOverflow a fair bit so with any luck you can get advice on that aspect fairly easily. If you get sufficient throughput with that algorithm then you're done. If not, look around for a faster algorithm. I recommend http://bouncycastle.org as a good crypto library. It has a bunch of algorithms implemented so you can experiment and find one that meets your needs.
Did I mention that you shouldn't roll your own encryption? Good.

Using boost unordered map

Guys, I am using dynamic programming approach to solve a problem. Here is a brief overview of the approach
Each value generated is identified using 25 unique keys.
I use the boost::hash_combine to generate the seed for the hash table using these 25 keys.
I store the values in a hash table declared as
boost::unordered_map<Key_Object, Data_Object, HashFunction> hashState;
I did a time profiling on my algorithm and found that nearly 95% of the run time is spent towards retrieving/inserting data into the hash table.
These were the details of my hash table
hashState.size() 1880
hashState.load_factor() 0.610588
hashState.bucket_count() 3079
hashState.max_size() 805306456
hashState.max_load_factor() 1
hashState.max_bucket_count() 805306457
I have the following two questions
Is there anything which I can do to improve the performance of the Hash Table's insert/retrieve operations?
C++ STL has hash_multimap which would also suit my requirement. How does boost libraries unordered_map compare with hash_multimap in terms of insert/retrieve performance.
If your hash function is not the culprit, the best you can do is probably using a different map implementation. Since your keys are quite large, using unordered_map from Boost.Intrusive library might be the best option. Alternatively, you could try closed hashing: Google SparseHash or MCT, though profiling is certainly needed because closed hashing is recommended when elements are small enough. (SparseHash is more established and well tested, but MCT doesn't need those set_empty()/set_deleted() methods).
EDIT:
I just noticed there is no intrusive map in the Boost library I mentioned, only set and multiset. Still, you can try the two closed hashing libraries.
EDIT 2:
STL hash_map is not standard, it is probably some extension and not portable across compilers.
Are you sure that the hash function you are using is not the bottleneck?
Which time percentage takes the hash function?
Can you do the same test and replace the insert/retrievals by a simple call to the hash.

Looking for pseudo code for hashing algorithms (open, chaining and multiple)

Greetings, I am looking for the pseudo code for "open", "chaining" abd "multiple hashing" algorithms. Yes I have been searching for a good amount of time at google but I wasn't able to get something good.
If you have a link to share, I will be greatful
regards
This hash table tutorial has examples of open and chaining collision resolution.
Bob Jenkins' Web Site has further examples of hash tables, perfect hashes and efficient hash functions.
I haven't found a satisfying explanation of multiple hashing (specifically why combining two different 32 bit hashes is considered better than a smooth 64 bit hash)
http://en.wikipedia.org/wiki/Cryptographic_hash_function
And from there:
http://en.wikipedia.org/wiki/MD5#Pseudocode
http://en.wikipedia.org/wiki/SHA_hash_functions#Examples_and_pseudocode
etc.

Resources