I hereby claim:
- I am spaceboatdvlp on github.
- I am looney (https://keybase.io/looney) on keybase.
- I have a public key ASA6HgV72uvd73puzqS9jomIYMO-kKh6rgwL761r6Hypfgo
To claim this, I am signing this object:
func validSquareSignature(req: Request) -> Bool { | |
guard let headerSignature: String = req.headers["x-square-signature"].first else { return false } | |
guard let urlData = "my webhook url".data(using: .utf8) else { return false } | |
guard let bodyData = req.body.string?.replacingOccurrences(of: " ", with: "").replacingOccurrences(of: "\n", with: "").data(using: .utf8) else { return false } | |
let payload = urlData + bodyData | |
var hmac = HMAC<Insecure.SHA1>(key: SymmetricKey(data: EnvVars.squareSig.data(using: .utf8) ?? Data())) | |
hmac.update(data: payload) | |
let mac = Data(hmac.finalize()).base64EncodedString() | |
return mac == headerSignature; | |
} |
I hereby claim:
To claim this, I am signing this object:
// | |
// ModelController.swift | |
// PageViewShenanigans | |
// | |
// Created by Steve Looney on 9/7/17. | |
// Copyright © 2017 Spaceboat Development, LLC. All rights reserved. | |
// | |
import UIKit |