sha1

Password hash function for Excel VBA

一世执手 提交于 2019-11-26 17:24:41
I need a function written in Excel VBA that will hash passwords using a standard algorithm such as SHA-1. Something with a simple interface like: Public Function CreateHash(Value As String) As String ... End Function The function needs to work on an XP workstation with Excel 2003 installed, but otherwise must use no third party components. It can reference and use DLLs that are available with XP, such as CryptoAPI. Does anyone know of a sample to achieve this hashing functionality? Chris Here's a module for calculating SHA1 hashes that is usable for Excel formulas eg. '=SHA1HASH("test")'. To

Compare two hex strings in Java?

与世无争的帅哥 提交于 2019-11-26 17:15:22
问题 I am implementing a simple DHT using the Chord protocol in Java. The details are not important but the thing I'm stuck on is I need to hash strings and then see if one hashed string is "less than" another. I have some code to compute hashes using SHA1 which returns a 40 digit long hex string (of type String in Java) such as: 69342c5c39e5ae5f0077aecc32c0f81811fb8193 However I need to be able to compare two of these so to tell, for example that: 0000000000000000000000000000000000000000 is less

Storing SHA1 hash values in MySQL

旧街凉风 提交于 2019-11-26 16:57:52
I have a simple question which occured when I wanted to store the result of a SHA1 hash in a MySQL database: How long should the VARCHAR field be in which I store the hash's result? Gumbo I would use VARCHAR for variable length data, but not with fixed length data. Because a SHA-1 value is always 160 bit long, the VARCHAR would just waste an additional byte for the length of the fixed-length field . And I also wouldn’t store the value the SHA1 is returning. Because it uses just 4 bit per character and thus would need 160/4 = 40 characters. But if you use 8 bit per character, you would only

RSA signature size?

时光毁灭记忆、已成空白 提交于 2019-11-26 15:49:54
问题 I would like to know what is the length of RSA signature ? Is it always the same size as the RSA key size like if the key size is 1024 then RSA signature is 128 bytes , if the key size is 512 bits then RSA signature is 64 bytes ? what is RSA modulus ? Also what does RSA-sha1 mean ? Any pointers greatly appreciated. 回答1: You are right, the RSA signature size is dependent on the key size, the RSA signature size is equal to the length of the modulus in bytes. This means that for a "n bit key",

How to SHA1 hash a string in Android?

冷暖自知 提交于 2019-11-26 15:49:01
In Objective C I've been using the following code to hash a string: -(NSString *) sha1:(NSString*)stringToHash { const char *cStr = [stringToHash UTF8String]; unsigned char result[20]; CC_SHA1( cStr, strlen(cStr), result ); return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15], result[16], result[17], result[18], result[19] ]; } Now I need the same for

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

眉间皱痕 提交于 2019-11-26 15:37:37
As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. How does Git calculate the SHA1 digest? Does it do it on the full uncompressed file contents? I would like to emulate assigning SHA1's outside of Git. Ferdinand Beyer 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

How to generate an HMAC in Java equivalent to a Python example?

房东的猫 提交于 2019-11-26 15:23:37
问题 I'm looking at implementing an app getting Twitter authorization via Oauth in Java. The first step is getting a request token. Here is a Python example for app engine. To test my code, I am running Python and checking output with Java. Here is an example of Python generating a Hash-Based Message Authentication Code (HMAC): #!/usr/bin/python from hashlib import sha1 from hmac import new as hmac key = "qnscAdgRlkIhAUPY44oiexBKtQbGY0orf7OV1I50" message = "foo" print "%s" % hmac(key, message,

How to hash NSString with SHA1 in Swift?

心已入冬 提交于 2019-11-26 15:08:00
In objective-c it looks like this: #include <sys/xattr.h> @implementation NSString (reverse) -(NSString*)sha1 { NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding]; uint8_t digest[CC_SHA1_DIGEST_LENGTH]; CC_SHA1(data.bytes, (int)data.length, digest); NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2]; for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) [output appendFormat:@"%02x", digest[i]]; return output; } @end I need something like this with Swift, is it possible? Please, show work example. Your Objective-C code (using a NSString category) can be

Calculating the info-hash of a torrent file

寵の児 提交于 2019-11-26 14:47:51
问题 I'm using C++ to parse the info hash of a torrent file, and I am having trouble getting a "correct" hash value in comparison to this site: http://i-tools.org/torrent I have constructed a very simple toy example just to make sure I have the basics right. I opened a .torrent file in sublime and stripped off everything except for the info dictionary, so I have a file that looks like this: d6:lengthi729067520e4:name31:ubuntu-12.04.1-desktop-i386.iso12:piece lengthi524288e6:pieces27820:¡´E¶ˆØËš3í

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

回眸只為那壹抹淺笑 提交于 2019-11-26 14:05:01
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? 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