sha1

Git - finding a filename from a SHA1

拜拜、爱过 提交于 2019-11-26 07:27:29
问题 I added a file to the index with: git add somefile.txt I then got the SHA1 for this file with: git hash-object somefile.txt I now have a SHA1 and I would like to retrieve the filename of the object in the index using the SHA1. git show 5a5bf28dcd7944991944cc5076c7525439830122 This command returns the file contents but not the name of the file. How do I get the full filename and path back from the SHA1? 回答1: There's no such direct mapping in git as the name of the file is part of the tree

Implementation HMAC-SHA1 in python

左心房为你撑大大i 提交于 2019-11-26 07:25:38
问题 I am trying to use the OAuth of a website, which requires the signature method to be \'HMAC-SHA1\' only. I am wondering how to implement this in Python? 回答1: Pseudocodish: def sign_request(): from hashlib import sha1 import hmac # key = b"CONSUMER_SECRET&" #If you dont have a token yet key = b"CONSUMER_SECRET&TOKEN_SECRET" # The Base String as specified here: raw = b"BASE_STRING" # as specified by OAuth hashed = hmac.new(key, raw, sha1) # The signature return hashed.digest().encode("base64")

How do I do a SHA1 File Checksum in C#?

狂风中的少年 提交于 2019-11-26 07:23:48
问题 How do I use the SHA1CryptoServiceProvider() on a file to create a SHA1 Checksum of the file? 回答1: using (FileStream fs = new FileStream(@"C:\file\location", FileMode.Open)) using (BufferedStream bs = new BufferedStream(fs)) { using (SHA1Managed sha1 = new SHA1Managed()) { byte[] hash = sha1.ComputeHash(bs); StringBuilder formatted = new StringBuilder(2 * hash.Length); foreach (byte b in hash) { formatted.AppendFormat("{0:X2}", b); } } } formatted contains the string representation of the SHA

Is it possible to get identical SHA1 hash? [duplicate]

对着背影说爱祢 提交于 2019-11-26 06:31:28
问题 This question already has an answer here: Probability of SHA1 collisions 3 answers Given two different strings S1 and S2 (S1 != S2) is it possible that: SHA1(S1) == SHA1(S2) is True? If yes - with what probability? If not - why not? Is there a upper bound on the length of a input string, for which the probability of getting duplicates is 0? OR is the calculation of SHA1 (hence probability of duplicates) independent of the length of the string? The goal I am trying to achieve is to hash some

How to add SHA-1 to android application

瘦欲@ 提交于 2019-11-26 06:05:57
问题 I\'m trying to create a dynamic link in Firebase, when I\'m selecting the android app, it shows an error saying \"Add SHA-1 to this android app\", I\'ve already added a credential, but I\'m not sure how exactly do I \"add SHA-1 to the app\" How is this done? 回答1: sha1 generation in android studio: Select Gradle in android studio from right panel Select Your App In tasks -> android-> signingReport Double click signingReport . You will find the sha1 fingerprint in the " Gradle Console " add

SHA1 vs md5 vs SHA256: which to use for a PHP login?

若如初见. 提交于 2019-11-26 05:54:58
问题 I\'m making a php login, and I\'m trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I still use a salt? Also, is this a secure way to store the password as a hash in mysql? function createSalt() { $string = md5(uniqid(rand(), true)); return substr($string, 0, 3); } $salt = createSalt(); $hash = sha1($salt . $hash); 回答1: Neither. You should use bcrypt . The hashes you mention are

SHA1 Key for DEBUG & RELEASE ANDROID STUDIO MAC

我的梦境 提交于 2019-11-26 05:23:51
问题 How do I get my SHA1 Keys for debug and release using android studio on a mac? (These are required for Google API Keys) 回答1: DEBUG: Click on the Gradle tab on the right hand side of the view. Go to the ROOT folder -> Tasks -> android -> signingReport Double click, this will build with the signingReport and post in your bottom view your SHA1. RELEASE: In android studio. Build -> Generate Signed APK... and click Next Copy your key store path and key alias. Traverse to the "bin" folder of the

Storing SHA1 hash values in MySQL

六眼飞鱼酱① 提交于 2019-11-26 04:58:43
问题 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? 回答1: 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

Probability of SHA1 collisions

喜你入骨 提交于 2019-11-26 04:53:32
Given a set of 100 different strings of equal length, how can you quantify the probability that a SHA1 digest collision for the strings is unlikely... ? Peter 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 bounded by the number of pairs of blocks multiplied by the probability that a given pair will collide. (source : http:/

Password hash function for Excel VBA

六眼飞鱼酱① 提交于 2019-11-26 04:41:09
问题 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? 回答1: Here