I have to encode a pass phrase with a “api secret” in SHA256 then base encode64 and send it to the rest api server but I can not manage to match what I get out of python with Julia.
There is SHA.jl and it has apparently the same function which is hmac_sha2_256 but when I set my inputs as “secret” and “pass” it gives “no method matching” for the first input. I tried to convert the first input to UInt8 with transcode() function still gives the same error. What am I doing wrong ?
I got the same value as python gives with the SHA.jl. There is no documentation for HMAC functionality in the SHA.jl albeit having all the SHA1 to 3. If you search hmac_sha256 in the terminal you get the bellow explanation:
No documentation found.
SHA.hmac_sha256 is a Function.
# 5 methods for generic function "hmac_sha256":
[1] hmac_sha256(key::Vector{UInt8}, data::Union{Tuple{Vararg{UInt8, N}} where N, AbstractVector{UInt8}}) in SHA at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/SHA/src/SHA.jl:99
[2] hmac_sha256(key::Vector{UInt8}, io::IO) in SHA at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/SHA/src/SHA.jl:125
[3] hmac_sha256(key::Vector{UInt8}, io::IO, chunk_size) in SHA at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/SHA/src/SHA.jl:125
[4] hmac_sha256(key::Vector{UInt8}, str::String) in SHA at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/SHA/src/SHA.jl:109
[5] hmac_sha256(key::Vector{UInt8}, str::AbstractString) in SHA at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/SHA/src/SHA.jl:108
Which I was mistakenly putting a string as my key and solved with a Vector{UInt8}(secret) input as key.
I still could not get the Nettle.jl to match, I don’t know what Im doing wrong there.