sha1

OK to use only 64-bits of sha1 hash as an id?

1) For the purpose of really low hash collision, can I get away with just using half of the 128 bits of a sha1 rather than dealing with the sha1 itself? I understand this is not suitable for cryptographic hashes, but I just need the hashes for hash table keys. 2) Computation time isn't a priority, and besides which I'm hashing very smal...

Objective-C sample code for HMAC-SHA1

I need to generate HMAC-SHA1 in Objective C. But i didnt find anything that works. I tried with CommonCrypto, using CCHMAC, but didnt works. I need to generate a hmac and after generate HOTP number. Somebody have any example code in Objective C or C? ...

C# SHA-1 vs. PHP SHA-1...Different Results?

Hey, I am trying to calculate a SHA-1 Hash from a string, but when I calculate the string using php's sha1 function I get something different than when I try it in C#. I need C# to calculate the same string as PHP (since the string from php is calculated by a 3rd party that I cannot modify). How can I get C# to generate the same hash as ...

How to hash a large object (dataset) in Python?

I would like to calculate a hash of a Python class containing a dataset for Machine Learning. The hash is meant to be used for caching, so I was thinking of md5 or sha1. The problem is that most of the data is stored in NumPy arrays; these do not provide a __hash__() member. Currently I do a pickle.dumps() for each member and calculate a...

Could validationKey and decryptionKey be found by brute force from encrypted cookie value?

I am using the following code to generate an encrypted token: var ticket = new System.Web.Security.FormsAuthenticationTicket( 2, "", DateTime.Now, DateTime.Now.AddMinutes(10), false, "user id here"); var cipherText = System.Web.Security.FormsAuthentication.Encrypt(ticket); This code uses the key and algori...

Performance of Oracle's dbms_crypto.hash function for SHA-1

Looking for stats for input sizes of at least between 4 and 30 MB. ...

SQL SHA1 inside WHERE

Hello, In my program, we store a user's IP address in a record. When we display a list of records to a user, we don't want to give away the other user's IP, so we SHA1 hash it. Then, when the user clicks on a record, it goes to a URL like this: http://www.example.com/allrecordsbyipaddress.php?ipaddress=SHA1HASHOFTHEIPADDRESS Now, I ne...

Git File Integrity

Recently my main machine i use for development started overheating. I started to get 4 5 lockups per day. Everything freezes. All my projects are under version control using git. I remember watching linus's talk at google saying git will ensure that the files are not corrupt. In my situation is it safe to assume that git will warn me if ...

hash collision and appending data

Assume I have two strings (or byte arrays) A and B which both have the same hash (with hash I mean things like MD5 or SHA1). If I concatenate another string behind it, will A+C and B+C have the same hash H' as well? What happens to C+A and C+B? I tested it with MD5 and in all my tests, appending something to the end made the hash the sa...

Calculating bittorent info_hash with java

I am trying to calculate the info_hash value for a torrent. I read the whole torrent into StringBuffer, then cut it like the following: d8:announce...info[d6:length...e]e I can't seem to get the correct hash. Does reading the torrent into a StringBuffer corrupt the byte string at the end? Am I missing something? public void calculate...

Verify integrity Ceritifcate { RSACryptoServiceProvider - SHA1 - thumbprint }

Hello, sorry for my english. I have a little problem. I want to verify the integrity of my certificat. I make this code: using System.Security.Cryptography; using System.Runtime.InteropServices; using System.Security.Cryptography.X509Certificates; SHA1Managed sha1 = new SHA1Managed(); RSACryptoServiceProvider csp = null; AsymmetricA...

Scala HMAC-SHA1 signing?

I was wondering if there would be a way to get a HMAC-SHA1 signature in scala without having to compile a java class with the code everyone use in java. Any ideas? ...

Can a SHA-1 hash be purely numeric?

Is there any chance that a SHA-1 hash can be purely numeric, or does the algorithm ensure that there must be at least one alphabetical character? Edit: I'm representing it in base 16, as a string returned by PHP's sha1() function. ...

Mysql SHA salt

Hello, I am setting a cookie something like: $_COOKIE['test'] = SHA1('124'.'mysalt'); Now 124 is my id which i want. So in my mysql table, I am trying to run a query like: $sql = ("SELECT * FROM users WHERE SHA1(`id`) = '".mysql_real_escape_string($_COOKIE['test'])."'"); Problem is how to do I add the "mysalt" to the sql query? Be...

How should i save my Password?

Hi I am programming a new site in JSF. At the moment i program the Login. I used md5 some years ago, but with Rainbow Tables i think its noch safe anymore. So, how should i store the Password in the Database ? ...

Understanding sha-1 collision weakness

According to various sources, attacks looking for sha-1 collisions have been improved to 2^52 operations: http://www.secureworks.com/research/blog/index.php/2009/6/3/sha-1-collision-attacks-now-252/ What I'd like to know is the implication of these discoveries on systems that are not under attack. Meaning if I hash random data, what ar...

iPhone SHA1 inconsistent

Hello everyone, I try to invoke the following code to get SHA1 working on the iPhone: uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0}; CC_SHA1(keyData.bytes, keyData.length, digest); keyData simply contains a constant string of hex code. However the hash hex that I get as a result of this does not match what online SHA1 generators output...

is HMACSHA1 defined for messages of zero length?

I have an edge case. I'm building code that reads binary datafiles produced by a commercial, closed source tool. The information on the data format is specified in a document. For data integrity checks, the vendor's spec calls for an HMAC based on SHA1, using a key derived from a password as per RFC2898. Many programming environments h...

SHA1 C# method equivalent in Perl?

I was given C# code and I'm trying to generate the equivalent SHA1 using Perl. public string GetHashedPassword(string passkey) { // Add a timstamp to the passkey and encrypt it using SHA1. string passkey = passkey + DateTime.UtcNow.ToString("yyyyMMddHH0000"); using (SHA1 sha1 = new SHA1CryptoServiceProvider()) ...

What are the chances that two messages have the same MD5 digest and the same SHA1 digest?

Given two different messages, A and B (maybe 20-80 characters of text, if size matters at all), what is the probability that the MD5 digest of A is the same as the MD5 digest of B and the SHA1 digest of A is the same as the SHA1 digest of B? That is: (MD5(A) == MD5(B)) && (SHA1(A) == SHA1(B)) Assume no malicious intent, i.e., that th...