hmac

PHP and Java hmac hash output matches in hex, doesn't match in raw binary. What's happening?

你说的曾经没有我的故事 提交于 2019-11-30 16:20:12
问题 I'm developing a game in Java that will be packaged as an applet, and I'm working on the networking aspect. I've designed a session flow that will work for the frequency of requests and the security needs, without requiring the use of SSL. The data transmission process is loosely based off of the way facebook signs their signed_token used with their OAuth process. Here's the simplified context: my php/java implementations use hash_hmac/javax.crypto.Mac to generate an obscured signature for

jsSHA, CryptoJS and OpenSSL libraries giving different results

有些话、适合烂在心里 提交于 2019-11-30 14:39:05
New to JS, I'm also learning to use crypto libraries. I don't understand why signing/encoding the same message with the same secret yields differing results. I'm using jsSHA 1.3.1 found here , and CryptoJS 3.0.2 described here trying to create a base64 sha-1 encoded hmac signature. Here's the code: In html... <script src="lib/jsSHA/src/sha1.js"></script> <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha1.js"></script> And in js... var message = "shah me"; var secret = "hide me"; var crypto = CryptoJS.HmacSHA1(message, secret).toString(CryptoJS.enc.Base64) + '='

Create OAuth Signature with HMAC-SHA1 Encryption returns HTTP 401

时光毁灭记忆、已成空白 提交于 2019-11-30 14:00:12
问题 The Question Hello, I need to authenticate to an API wich needs OAuth encryption. I'm in the right direction but I am sure something is wrong with my signature base string. Since the HMACSHA1 Hash is based on a Key and BaseString, I get a wrong oauth_signature. OAuth Signing Process So far I have been able to collect all the required pieces of data, which includes: Consumer Key Consumer Secret Acces Token Acces Secret Sha1Hased Value (Based on Key and Message, where Message is the signature

HMAC security - Is the security of the HMAC based on SHA-1 affected by the collisions attacks on SHA-1?

十年热恋 提交于 2019-11-30 11:38:42
Is the security of the HMAC based on SHA-1 affected by the collisions attacks on SHA-1? Nick Johnson The security implications of HMAC are described in detail in the security section of the RFC . In a nutshell, a very strong attack indeed is required before the security of the HMAC is threatened; the existing collision attacks on SHA-1 certainly don't constitute such. HMAC is specifically designed to make attacks difficult, and ordinary collision attacks won't generally suffice: The security of the message authentication mechanism presented here depends on cryptographic properties of the hash

C# help required to Create Facebook AppSecret_Proof HMACSHA256

社会主义新天地 提交于 2019-11-30 08:54:53
Facebook requires that I create a appsecret_proof: https://developers.facebook.com/docs/graph-api/securing-requests And I have done this using the following code: public string FaceBookSecret(string content, string key) { var encoding = new System.Text.ASCIIEncoding(); byte[] keyByte = encoding.GetBytes(key); byte[] messageBytes = encoding.GetBytes(content); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); return Convert.ToBase64String(hashmessage); } } Everything looks fine for me, however facebook says that the appsecret_proof is

How can I decrypt a HMAC?

我只是一个虾纸丫 提交于 2019-11-30 05:05:45
I can make an HMAC using the following: var encrypt = crypto.createHmac("SHA256", secret).update(string).digest('base64'); I am trying to decrypt an encoded HMAC with the secret: var decrypt = crypto.createDecipher("SHA256", secret).update(string).final("ascii"); The following was unsuccessful. How can I decrypt a HMAC with the key? I get the following error: node-crypto : Unknown cipher SHA256 crypto.js:155 return (new Decipher).init(cipher, password); ^ Error: DecipherInit error HMAC is a MAC/keyed hash, not a cipher. It's not designed to be decrypted. If you want to encrypt something, use a

Securing a javascript client with hmac

丶灬走出姿态 提交于 2019-11-30 03:51:23
问题 I am researching ways to secure a javascript application I am working on. The application is a chat client which uses APE (Ajax Push Engine) as the backend. Currently, anyone can access the page and make a GET/POST request to the APE server. I only want to serve the chat client to registered users, and I want to make sure only their requests will be accepted. I can use username/password authentication with PHP to serve a user the page. But once they have the page, what's to stop them from

How much can you truncate a SHA1 hash and be reasonably sure of having an unique ID?

孤者浪人 提交于 2019-11-30 01:54:46
I am making an application that stores documents and gives each one a UID based on a SHA1 digest of a few things including the timestamp. The digest has a lot of characters, and I want to allow users to identify the documents by using the first x characters of the full digest. What's a good value for x if the number of documents is maybe around 10K - 100K? bdonlan Adapting the formulas on on wikipedia for the Birthday problem , you can approximate the probability of collision as e^(-n^2/(2^(b+1))) , where n is the document count and b is the number of bits. Graphing this formula with n=100,000

python常用模块1

▼魔方 西西 提交于 2019-11-29 14:04:37
目录 time模块 datetime模块 random模块 os模块 sys模块 json模块 pickle模块 hashlib模块 hash是什么 撞库破解hash算法加密 hmac模块 logging模块 time模块 打印时间戳、格式化时间、结构化时间,总而言之就是打印不同类型的时间,进行不同类型时间的转换 import time # 时间戳 time.time() (*****) # 格式化时间 time.strftime('%Y-%m-%d %X') # 结构化时间 time.localtime() # 北京时间 time.gmtime() # 格林威治时间 time.gmtime(0) # 1970/1/1/0:00 # 时间的转换(了解中的了解) # 结构化时间转换为时间戳 now = time.localtime() time.mktime(now) # 结构化时间转格式化时间 time.strftime('%Y-%m-%d %X', now) # 2019-06-11 08:45:30 time.strftime('%Y-%m-%d', now) # 2019-06-11 # 格式化时间转结构化时间 now = time.strftime('%Y-%m-%d %X') time.strptime(now,'%Y-%m-%d %X') time.strptime(

Python HMAC-SHA1 vs Java HMAC-SHA1 different results

纵饮孤独 提交于 2019-11-29 11:11:23
I borrowed the HMAC-SHA1 Java code from http://tools.ietf.org/html/rfc6238 and adapted slightly to hardcode it to use one known key/message pair with known output. I then tried to write the same code in Python to verify the results, however I'm getting different values in Python and Java. The Java values are known to be good. Java code: import java.lang.reflect.UndeclaredThrowableException; import java.security.GeneralSecurityException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import