hmac

PBKDF2 with HMAC in Java

余生长醉 提交于 2019-12-07 06:08:58
问题 This question was migrated from Information Security Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I am working on a Java project where I must ensure the confidentiality and integrity of users password saved in a plaintext file. To do so, I will write only a hash of the password in the file. More specifically, my intention is to write the hash of the password and a random salt, plus the random salt itself, to avoid the use of rainbow and lookup tables. I

How can I replicate this C# hashing in PHP? (toByteArray(), ComputeHash())

自作多情 提交于 2019-12-07 05:02:33
问题 I am trying to replicate the following code in PHP , It is example code for an API I have to interface with (The API & Example code is in C# , My app is in PHP 5.3 ). I'm not a C# developer and so am having trouble doing this. // C# Code I am trying to replicate in PHP var apiTokenId = 1887; var apiToken = "E1024763-1234-5678-91E0-T32E4E7EB316"; // Used to authenticate our request by the API (which is in C#) var stringToSign = string.Empty; stringToSign += "POST"+"UserAgent"+"http://api.com

Using HMAC vs EVP functions in OpenSSL

喜欢而已 提交于 2019-12-07 02:01:12
问题 This is a very basic question, but what is the difference between EVP and HMAC? EVP is a message digest, but how does that differ from what is generated by HMAC? 回答1: ... what is the difference between EVP and HMAC EVP_* functions are a high level interface. HMAC_* , AES_* and friends are lower level primitives. You can work with either, but its recommended you work with the EVP_* functions. The HMAC_* routines are software based and don't use hardware. The EVP_* functions will allow you to

JWT Token Invalid Signature [duplicate]

寵の児 提交于 2019-12-07 01:50:53
问题 This question already has an answer here : PHP JWT Token Invalid Signature (1 answer) Closed 2 years ago . I am using JWT in my application for login authentication process. To generate the token I am using: Jwts.builder().setSubject(username).signWith(SignatureAlgorithm.HS512, MacProvider.generateKey()).compact(); Generated Token: eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJlaG91c2VAZGV2ZXJldXgub3JnIn0.5SX-aU-p_RlfC3CZa-YXnQu_YR7RsG2Xfim3LOmlqxjAZrIyZiz0fYZwViHr113ms8TNvngcJcV07U4hK-RBZQ When I decode

Hmac Hashing Error in Python 3.5

做~自己de王妃 提交于 2019-12-06 15:44:06
I'm trying to hash an API secret using hmac. But I can't get it to work using Python 3.5. Here's the problem code: sign = hmac.new(self.Secret, post_data, hashlib.sha512).hexdigest() Here's the error: TypeError: key: expected bytes or bytearray, but got 'str' I've tried encoding first like so... secret = b'api_secret_here' Also tried... sign = hmac.new(self.Secret.encode('utf-8'), post_data, hashlib.sha512).hexdigest() and... sign = hmac.new(self.Secret.encode(), post_data, hashlib.sha512).hexdigest()
 All give the error: TypeError: Unicode-objects must be encoded before hashing Here's the

HMAC SHA512 using CommonCrypto in Swift 3.1 [duplicate]

筅森魡賤 提交于 2019-12-06 14:58:34
问题 This question already has answers here : CommonHMAC in Swift (10 answers) Closed 2 years ago . I'm trying to encrypt data to send to the API. The API requires the data to be sent as hmac_sha512 encrypted hash. I've found various examples of how it possibly could have been done for sha1 and others (not sha512 ) and also in older versions of Swift. None of the examples that I tried work for swift 3.1 Any help in the right direction will be appreciated. Edit: In PHP, I successfully send it using

AES-Encrypt-then-MAC a large file with .NET

帅比萌擦擦* 提交于 2019-12-06 12:48:32
I want to encrypt a large file (lets say 64 GB) in the most efficient way in .NET. How I would implement this: Create an instance of AesManaged to encrypt the stream of the file (read 64 GB) Save this stream to disk (because it is to big to hold in memory) (write 64 GB) Create an instance of HMACSHA512 to compute hash of the saved file (read 64 GB) Save encrypted data with iv to disk (read & write 64 GB) Simplified C# Code: using (var aesManaged = new AesManaged()) { using (var msEncrypt = File.OpenWrite(@"C:\Temp\bigfile.bin.tmp")) { using (var csEncrypt = new CryptoStream(msEncrypt,

Using CommonCrypto/CommonHMAC to encrypt some data and always comes back null

大兔子大兔子 提交于 2019-12-06 06:07:45
I tried the following to encrypt the clearTextData using the key keyData . And I did check to make sure that both of those values are valid and going through. NSData *keyData = [PRIVATE_KEY dataUsingEncoding:NSUTF8StringEncoding]; NSData *clearTextData = [data dataUsingEncoding:NSUTF8StringEncoding]; uint8_t digest[CC_SHA1_DIGEST_LENGTH] = {0}; CCHmacContext hmacContext; CCHmacInit(&hmacContext, kCCHmacAlgSHA1, keyData.bytes, keyData.length); CCHmacUpdate(&hmacContext, clearTextData.bytes, clearTextData.length); CCHmacFinal(&hmacContext, digest); NSData *out = [NSData dataWithBytes:digest

trying to mock github webhook request, get: “X-Hub-Signature does not match blob signature”

岁酱吖の 提交于 2019-12-06 05:27:20
问题 Here is a little proxy server setup to handle github webhooks: require('dotenv').config(); var http = require('http'); var createHandler = require('github-webhook-handler'); var handler = createHandler({ path: '/webhook', secret: process.env.GIT_WEBHOOK_SECRET }); http .createServer(function(req, res) { handler(req, res, function(err) { res.statusCode = 404; res.end('no such location'); }); }) .listen(8080); handler.on('error', function(err) { console.error('Error:', err.message); }); handler

HMAC, Elixir, Plug.Conn (trying to call read_body more than once)

安稳与你 提交于 2019-12-06 01:22:22
I'm struggling with an issue where something is reading the body of an http request before Plug.Parsers.JSON gets it in the pipeline. Because of this, read_body in the plug for json times out--you can't read the body twice. We have an HMAC implementation in an earlier plug in our pipeline and it reads the body in some cases. Is there a pattern for how use of the body is to behave in Plug? I mean, if we can only read it once, and it has to be decoded in Plug.Parsers.JSON, well...it's not going to work. Follow on question. Do we need to include the request body when we generate the HMAC hash? I