sha1

How to generate random SHA1 hash to use as ID in node.js?

时光怂恿深爱的人放手 提交于 2019-11-27 16:36:00
I am using this line to generate a sha1 id for node.js: crypto.createHash('sha1').digest('hex'); The problem is that it's returning the same id every time. Is it possible to have it generate a random id each time so I can use it as a database document id? Gabi Purcaru Have a look here: How do I use node.js Crypto to create a HMAC-SHA1 hash? I'd create a hash of the current timestamp + a random number to ensure hash uniqueness: var current_date = (new Date()).valueOf().toString(); var random = Math.random().toString(); crypto.createHash('sha1').update(current_date + random).digest('hex');

Compare two hex strings in Java?

本秂侑毒 提交于 2019-11-27 15:40:50
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 than: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF This is the complete range of values as the 40 digit

SignTool Not Signing ClickOnce App Using SHA256, Only Uses SHA1

Deadly 提交于 2019-11-27 14:57:41
问题 I'm trying to sign my clickonce app. I have an EV code signing certificate that is using SHA256. The problem is that when I sign my app using the post build commands, it seems to be using SHA1 instead of SHA256. Here is a clip of the output window: Running Code Analysis... 1> Code Analysis Complete -- 0 error(s), 0 warning(s) 1> The following certificate was selected: 1> Issued to: Certificate Subject Name Here 1> 1> Issued by: DigiCert EV Code Signing CA (SHA2) 1> 1> Expires: Thu Apr 14 06

SHA1 hashing in SQLite: how?

这一生的挚爱 提交于 2019-11-27 14:51:26
Working with several DBs in parallel and need to initialize some records with hashed passwords. In MS SQL server there are handy functions that allow to hash on the fly: HashBytes('SHA1', CONVERT(nvarchar(32), N'admin')) Is there is a similar function with SQLite ? If not, which is the easiest workaround (such as select from SQL server and somehow insert it into SQLite tables)? The preferred hashing algorithm is SHA1 and the passwords are stored in a BLOB column. Update: I use C# language in the current project. kennytm There is no such function built into SQLite3. But you could define a user

A Regex to match a SHA1

半世苍凉 提交于 2019-11-27 12:03:15
I'm trying to match SHA1's in generic text with a regular expression. Ideally I want to avoid matching words. It's safe to say that full SHA1's have a distinctive pattern (they're long and a consistent length) - so I can match these reliably - but what about abbreviated SHA1's? Can I rely on the presence of numbers? Looking at the SHA1's in my commit log - numbers always appear in the first 3 characters. But is this too short? How many characters of SHA1 do I need to consider before I can assume a number would have appeared? This does not have to be 100% accurate - I just need to match an

RSA signature size?

廉价感情. 提交于 2019-11-27 11:54:35
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. emboss 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", the resulting signature will be exactly n bits long. Although the computed signature value is not

How to Use SHA1 or MD5 in C#?(Which One is Better in Performance and Security for Authentication)

回眸只為那壹抹淺笑 提交于 2019-11-27 11:05:29
问题 In C# how we can use SHA1 automatically? Is SHA1 better than MD5?(We use hashing for user name and password and need speed for authentication) 回答1: Not sure what you mean by automatically, but you should really use SHA256 and higher. Also always use a Salt (code) with your hashes. A side note, after time has passed, using hardened hashes is far better than using a plain speed-based hashing function. I.e.: hashing over a few hundred iterations, or using already proven hashing functions such as

Issues with SHA1 hash implementation in Android

牧云@^-^@ 提交于 2019-11-27 11:01:49
问题 I have two small snippets for calculating SHA1. One is very fast but it seems that it isn't correct and the other is very slow but correct. I think the FileInputStream conversion to ByteArrayInputStream is the problem. Fast version: MessageDigest md = MessageDigest.getInstance("SHA1"); FileInputStream fis = new FileInputStream("path/to/file.exe"); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(fis.toString().getBytes()); DigestInputStream dis = new DigestInputStream

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

人盡茶涼 提交于 2019-11-27 11:01:41
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, sha1).digest().encode('base64')[:-1] Output: $ ./foo.py +3h2gpjf4xcynjCGU5lbdMBwGOc= How does one

iPhone and HMAC-SHA-1 encoding

一世执手 提交于 2019-11-27 10:02:56
问题 im trying to get a call to amazon web service and im stuck on getting the signature, looked at this but i still have a question on it. using this example what is the NSData *keyData; NSData *clearTextData ? what do i need to pass for these two values? /* inputs: NSData *keyData; NSData *clearTextData */ uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0}; CCHmacContext hmacContext; CCHmacInit(&hmacContext, kCCHmacAlgSHA1, keyData.bytes, keyData.length); CCHmacUpdate(&hmacContext, clearTextData.bytes,