Hashing a file in Python

TL;DR use buffers to not use tons of memory. We get to the crux of your problem, I believe, when we consider the memory implications of working with very large files. We don’t want this bad boy to churn through 2 gigs of ram for a 2 gigabyte file so, as pasztorpisti points out, we … Read more

Objective-C sample code for HMAC-SHA1 [closed]

Here’s how you generate an HMAC using SHA-256: NSString *key; NSString *data; const char *cKey = [key cStringUsingEncoding:NSASCIIStringEncoding]; const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding]; unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH]; CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC); NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC length:sizeof(cHMAC)]; NSString *hash = [HMAC base64Encoding]; I’m not aware of an HOTP library, but the algorithm … Read more

How can I get the MD5 fingerprint from Java’s keytool, not only SHA-1?

With JDK 1.7 installed, keytool always outputs by default SHA1 fingerprint, not MD5. you can get the MD5 Certificate by adding -v option. use the following code:- C:\Program Files\Java\jdk1.7.0\bin>keytool -v -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android it will output MD5 certificate as well.

How to assign a Git SHA1’s to a file without Git?

This is how Git calculates the SHA1 for a file (or, in Git terms, a “blob”): sha1(“blob ” + filesize + “\0″ + data) So you can easily compute it yourself without having Git installed. Note that “\0” is the NULL-byte, not a two-character string. For example, the hash of an empty file: sha1(“blob 0\0”) … Read more

Is it possible to reverse a SHA-1?

No, you cannot reverse SHA-1, that is exactly why it is called a Secure Hash Algorithm. What you should definitely be doing though, is include the message that is being transmitted into the hash calculation. Otherwise a man-in-the-middle could intercept the message, and use the signature (which only contains the sender’s key and the timestamp) … Read more

Probability of SHA1 collisions

Are the 160 bit hash values generated by SHA-1 large enough to ensure the fingerprint of every block is unique? Assuming random hash values with a uniform distribution, a collection of n different data blocks and a hash function that generates b bits, the probability p that there will be one or more collisions is … Read more

Generate SHA-1 for Flutter/React-Native/Android-Native app

TERMINAL Go to the project folder in the terminal. Mac keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android Windows keytool -list -v -keystore “\.android\debug.keystore” -alias androiddebugkey -storepass android -keypass android Linux keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android GUI Android Studio. Select android/app/build.gradle file and on the right … Read more

How does the newly found SHA-1 collision affect Git?

Edit, late December 2017: Git version 2.16 is gradually acquiring internal interfaces to allow for different hashes. There is a long way to go yet. The short (but unsatisfying) answer is that the example files are not a problem for Git—but two other (carefully calculated) files could be. I downloaded both of these files, shattered-1.pdf … Read more

tech