sha1

HMAC-SHA1: How to do it properly in Java?

匆匆过客 提交于 2019-11-28 03:39:20
I'm hashing some values using HMAC-SHA1, using the following code in Java: public static String hmacSha1(String value, String key) { try { // Get an hmac_sha1 key from the raw key bytes byte[] keyBytes = key.getBytes(); SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1"); // Get an hmac_sha1 Mac instance and initialize with the signing key Mac mac = Mac.getInstance("HmacSHA1"); mac.init(signingKey); // Compute the hmac on input data bytes byte[] rawHmac = mac.doFinal(value.getBytes()); // Convert raw bytes to Hex byte[] hexBytes = new Hex().encode(rawHmac); // Covert array of

Java's MessageDigest SHA1-algorithm returns different result than SHA1-function of php

半腔热情 提交于 2019-11-27 22:21:19
I have a SQL table with usernames and passwords. The passwords are encoded using MessageDigest's digest() method. If I encode a password - let's say "abcdef12" - with MessageDigest's digest() method and then convert it to hexadecimal values, the String is different than if I do the same using PHP's SHA1-method. I'd expect these values to be exactly the same though. Code that is used to encode the passwords: MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] passbyte; passbyte = "abcdef12".getBytes("UTF-8"); passbyte = md.digest(passbyte); The conversion of the String to hexadecimal

Why does git hash-object return a different hash than openssl sha1?

风格不统一 提交于 2019-11-27 20:22:25
Context: I downloaded a file (Audirvana 0.7.1.zip) from code.google to my Macbook Pro (Mac OS X 10.6.6). I wanted to verify the checksum, which for that particular file is posted as 862456662a11e2f386ff0b24fdabcb4f6c1c446a (SHA-1). git hash-object gave me a different hash, but openssl sha1 returned the expected 862456662a11e2f386ff0b24fdabcb4f6c1c446a. The following experiment seems to rule out any possible download corruption or newline differences and to indicate that there are actually two different algorithms at play: $ echo A > foo.txt $ cat foo.txt A $ git hash-object foo.txt

Understanding sha-1 collision weakness

大城市里の小女人 提交于 2019-11-27 19:54:50
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 are the statistical odds of a collision? Said another way, does the recent research indicate that a brute-force birthday attack has a higher chance of finding collisions that originally proposed? Some writeups, like the one above, say that obtaining a SHA-1

SHA1 collision demo / example

坚强是说给别人听的谎言 提交于 2019-11-27 19:21:30
This question is similar to this , but that one only references MD5 collision demos. Are there any actual SHA1 collision pairs of arbitrary messages known so far ? I'd like to use these to test how various software products (my own one and some third party) deal with it. Doing some Google searches only turned up the oh-so prominent MD5 / SHA0 collisions and some hints on an approach to creating SHA1 collisions but I could not get my hands on any examples. The first known collision has now been published at https://shattered.it/ Thomas Pornin As of February 23rd 2017 this answer is no longer

Git - finding the SHA1 of an individual file in the index

空扰寡人 提交于 2019-11-27 17:42:21
I've added a file to the 'index' with: git add myfile.java How do I find out the SHA1 of this file? You want the -s option to git ls-files . This gives you the mode and sha1 hash of the file in the index. git ls-files -s myfile.java Note that you do not want git hash-object as this gives you the sha1 id of the file in the working tree as it currently is, not of the file that you've added to the index. These will be different once you make changes to the working tree copy after the git add . rsp It's an old question but one thing needs some clarification: This question and the answers below

Hashing with SHA1 Algorithm in C#

大憨熊 提交于 2019-11-27 17:40:54
I want to hash given byte[] array with using SHA1 Algorithm with the use of SHA1Managed . The byte[] hash will come from unit test. Expected hash is 0d71ee4472658cd5874c5578410a9d8611fc9aef (case sensitive). How can I achieve this? public string Hash(byte [] temp) { using (SHA1Managed sha1 = new SHA1Managed()) { } } Mitch For those who want a "standard" text formatting of the hash, you can use something like the following: static string Hash(string input) { using (SHA1Managed sha1 = new SHA1Managed()) { var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(input)); var sb = new StringBuilder(hash

one way SHA1 hash javascript implementation?

99封情书 提交于 2019-11-27 17:02:53
问题 I have a server that is not using SSL, so I'm trying to find a way to secure the data being passed to the server. My first thought was jCryption, but it is not exactly what I need. So what I decided is that I could just pre-hash the password and send it to the server for comparison. So my question is, is there a sha1 utility that can be used for password verification purposes with PHP? 回答1: Try the Stanford Crypto library. It's pretty comprehensive but if you just need a single hashing

How do I generate my MD5 and SHA1 thumbprints using eclipse for debug keystore (Android)

五迷三道 提交于 2019-11-27 17:01:45
问题 Can I generate my MD5 and SHA1 thumbprints using eclipse for my debug keystore? also is there a code for to generate my hash key for facebook as well? 回答1: get your sha1 and md5 thumbprint for debug keystore (also works for your other keystores). Go to you package exporler in eclipse (defaults to the left side) right click it>android tools>export signed application package Then navigate to your debug keystore normally in your .android folder and select it Then enter the password which is

How insecure is a salted SHA1 compared to a salted SHA512

南笙酒味 提交于 2019-11-27 16:38:37
问题 SHA1 is completely insecure and should be replaced. This question is 8+ years old and times have changed: https://arstechnica.com/information-technology/2017/02/at-deaths-door-for-years-widely-used-sha1-function-is-now-dead/ For passwords: https://en.wikipedia.org/wiki/PBKDF2 For data: SHA3 SHA512 is more complex than SHA1, but how much security am I losing by hashing a salted password with SHA1 compared to hashing it with 512? in terms of the time it would take for someone who has the db to