swift3 - have HMAC SHA256 in pure Swift (Vapor) project -


i new in swift based vapor backend framework, setup helloworld project.

i need use hmac sha256 algorithm encrypt data. searched on internet, , found something this, based on ios or osx framework, uses c library , can added import <commoncrypto/commonhmac.h>.

how can add commoncrypto or hmac vapor project? if impossible, how can have pure swift hmac sha256 algorithm? there such dependency can add package.swift ?

if you're using vapor 0.17 or later, should able import hmac , import sha2

from there can create sha1 hashes using hmac.

check out crypto package vapor uses: https://github.com/vapor/crypto

additionally, vapor's default hasher sha256 hmac. can drop.hash.make("foo") , work.


Comments