SweetHMAC是个极小,简单易用的Swift类,使用HMAC算法加密字符串。
字符串扩展:
// Will output this strig: e470f785afb708cd8c2a31860642fd11"I'm goig to make him a offer he ca't refuse".HMAC(.MD5, secret:"Vito Corleoe")HMAC:
let quote = "I'm goig to make him a offer he ca't refuse"let author = "Vito Corleoe"// Create a SweetHMAC istace with your message ad secret strigslet hmacEcrypt:SweetHMAC = SweetHMAC(source: quote, secret: author)// Pick some computed HMAC output based o some algorithm usig "HMAC" method...let md5 = hmacEcrypt.HMAC(.MD5)// ...or do it more "Sweet" like thislet md5 = SweetHMAC(source: quote, secret: author).HMAC(.MD5)
评论