Hi,
I am using google direction web service in my application . I want to authenticate url using client id and digital signature. For that i need to use HMAC algorithm .
I tried as given in link : https://github.com/googlemaps/url-signing/blob/gh-pages/URLSigner.swift
import CryptoSwift
class URLSigner: NSObject {
static func sign(key: String, secret: String) -> URL?{
let path = "/path/something"
var secret_key = secret
secret_key = secret_key.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
if let decodedData = Data(base64Encoded: secret_key)?.bytes,
let hmac = try? HMAC(key: decodedData, variant: .sha1).authenticate(Array(path.utf8)), var signature = hmac.toBase64(){
signature = signature.replacingOccurrences(of: "+", with: "-").replacingOccurrences(of: "/", with: "_")
return URL(string: "URL" + path + "&signature=" + signature)
}
return URL(string: "URL" + path)
}
}But i am getting error : Ambiguous use of 'bytes' in the below line of code
let decodedData = Data(base64Encoded: secret_key)?.byteshow to resolve it .
Please help .