hmac

Why would HMAC SHA-1 return a different digest with the same input?

谁说我不能喝 提交于 2019-12-05 00:24:58
问题 I am trying to build a working encrypted signature for the Amazon S3 web service, writing a connection library using Objective C. I have run into HMAC SHA-1 digest problems with the ObjC code, so I'm putting that to the side and looking at existing, working Perl code, to try to troubleshoot digest creation. I am testing HMAC SHA-1 digest output from the s3ls command of the Net::Amazon::S3 package and comparing that against the _encode subroutine that I pulled out and put into its own perl

Spring Boot. HMAC authentication. How to add custom AuthenticationProvider and Authentication filter?

帅比萌擦擦* 提交于 2019-12-05 00:16:35
问题 To implement HMAC authentication I made my own filter, provider and token. RestSecurityFilter: public class RestSecurityFilter extends AbstractAuthenticationProcessingFilter { private final Logger LOG = LoggerFactory.getLogger(RestSecurityFilter.class); private AuthenticationManager authenticationManager; public RestSecurityFilter(String defaultFilterProcessesUrl) { super(defaultFilterProcessesUrl); } public RestSecurityFilter(RequestMatcher requiresAuthenticationRequestMatcher) { super

Java HmacSHA256 with key

半腔热情 提交于 2019-12-04 21:38:31
i have tried several links from stackoverflow to get HmacSHA256 with key to work with java, but i always get func check(body: String) -> String { let hash = body.hmac(HMACAlgorithm.sha256, key: Router.sigKey) print("SIG: " + Router.sigKey) print("result of hash. \(hash)") return hash } This function returns hash with key from given String. Key was: 0393e944ee8108bb66fc9fa4f99f9c862481e9e0519e18232ba61b0767eee8c6 String was: example Result is: 27effb76c97022497e25d3a5d7e823462f212a82d9ebba35f179071568b0c335 When i use this website to check if my SHA256 is good with the same key, it returns same

HMAC SHA512 using CommonCrypto in Swift 3.1 [duplicate]

纵饮孤独 提交于 2019-12-04 20:41:42
This question already has an answer here: CommonHMAC in Swift 10 answers 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: $sign = hash_hmac('sha512', $post_data, $this->secret); Edit 2: I did add briding header , I don't know what to do next! As

Converting HMAC-SHA1 from node.js to Java

▼魔方 西西 提交于 2019-12-04 19:26:47
I have been tasked with converting some existing piece of node.js code to Java. I think I'm well on my way, but I'm kind of stuck right now. The output of the methods do not seem to match. What I'm doing is creating a SHA-1 signature based on a query string. This query string contains some query-related data (not relevant for this question) and an API key. Important The api_secret string in node.js is equivalent to Config.API_SECRET in Java. Example query string (these are equal in the node.js and Java program): /events?festival=imaginate&pretty=1&size=100&from=0&key=SOME_KEY Actual code The

How to use pagination at api localbitcoin

夙愿已清 提交于 2019-12-04 19:19:09
I'm developing with localbitcoin API and i am using path “/api/dashboard/closed/” and this is my code: <?php function localbitcoinsquery($path, $nonce,array $req = Array()) { global $random; $key='mykey'; $secret='secretkey'; if ($req) { $get=httpbuildquery($req); $path=$path.'?'.$get; } $postdata=$nonce.$key.$path; $sign = strtoupper(hashhmac('sha256', $postdata, $secret)); $headers = array( 'Apiauth-Signature:'.$sign, 'Apiauth-Key:'.$key, 'Apiauth-Nonce:'.$nonce ); $ch = null; $ch = curlinit('https://localbitcoins.com'.$path); curlsetopt($ch, CURLOPTRETURNTRANSFER, true); curlsetopt($ch,

HMAC-SHA256 issue in Shopify oauth (Output does not match)

て烟熏妆下的殇ゞ 提交于 2019-12-04 18:30:48
I'm trying to publish an app on Shopify marketplace by following this documentation. And I'm stuck on step-3 of the oauth documentation wherein you have to do 'HMAC Signature Validation'. Documentation states that you have to process the string (specified below) through HMAC-SHA256 using app's shared secret key. String = "shop=some-shop.myshopify.com&timestamp=1337178173" I'm trying to implement the steps using Java. Following is gist of the code that I have used. private static final String HMAC_ALGORITHM = "HmacSHA256"; String key = "hush"; String data = "shop=some-shop.myshopify.com

Passing hashed data as key to hash again returns incorrect results

被刻印的时光 ゝ 提交于 2019-12-04 17:35:39
I'm creating a script that will access AWS services using GAS. I'm using the hashing functions in the Utilities library for all the hashing that is required to create a v4 signature. These functions appear to be able to successfully hash data once, but trying to pass in hashed data into an argument yields incorrect results. Anyone else run into this issue and figure it out? I know there is something weird going on with Utilities.computeHmacSha256Signature( input, key ) , because the arguments can only be byte arrays or strings, and I am passing in combinations of the two. However, when I try

Android (Java) method equivalent to Python HMAC-SHA256 in Hex

ぃ、小莉子 提交于 2019-12-04 14:51:59
问题 I am attempting to replicate the Python HMAC-SHA256 equivalent in Android (Java). The Python representation is shown bellow with the correct output: Python print (hmac.new(key = binascii.unhexlify("0123465789"),msg = binascii.unhexlify("ABCDEF"),digestmod=hashlib.sha256).hexdigest()).upper() Output 5B5EE08A20DDD645A31384E51AC581A4551E9BE5AC8BF7E690A5527F2B9372CB However, I am unable to get the same output in Java using the code below: Java Mac sha256_HMAC = Mac.getInstance("HmacSHA256");

腾讯微博Android客户端开发

我只是一个虾纸丫 提交于 2019-12-04 14:48:03
http://wiki.open.t.qq.com/index.php/OAuth%E6%8E%88%E6%9D%83%E8%AF%B4%E6%98%8E 目录 1 腾讯微博 API OAuth认证介绍 2 OAuth是什么? 3 OAuth的原理认证流程及访问资源流程 3.1 请求签名说明 3.2 获取未授权的Request Token 3.2.1 请求参数 3.2.2 返回参数 3.2.2.1 示例: 3.2.3 返回结果 3.3 请求用户授权Request Token 3.4 使用授权后的Request Token换取Access Token 3.5 使用包含Access Token的OAuth标准参数访问腾讯微博 3.6 示例 腾讯微博 API OAuth认证介绍 腾讯微博开放平台,是基于腾讯微博系统,为广大开发者和用户提供的开放数据分享与传播平台。 广大开发者和用户登录平台后,就可以使用平台提供的开放API接口,创建应用从微博系统获取信息,或将新的信息传播到整个微博系统中,丰富多样的API接口和应用,加上您的智慧,将创造出无穷的应用和乐趣。 腾讯微博API采用OAuth协议为第三方提供接入服务,遵循[RFC-5849]规范。有关OAuth认证的详细说明,请阅读官方OAuth规范。各种语言的OAuth 客户端可以在Google-OAuth项目里找到。