Convert encryption to String
func sign (dict:Dictionary<string,string>?,_ sign:string) String {
Let sortdict = dict?. sort{$0.0 < $1.0}
var params = ""
for (Key,value) in sortdict! {
params + = "\ (key) =\ (value) &"
}
Let index = params. endIndex. Advancedby (-1)
params = Params.substringtoindex (index)
Let Signstr = sign + params + sign
return params + "&sign=" + MD5 (SIGNSTR)
}
MD5 encryption
func MD5 (sstring: string), string{
Let str = sstring.cstringusingencoding (nsutf8stringencoding)
Let StrLen = Cc_long (sstring.lengthofbytesusingencoding (nsutf8stringencoding))
Let Digestlen = Int (cc_md5_digest_length)
Let buffer = Unsafemutablepointer<uint8>.alloc (Digestlen)
CC_MD5 (Str!,strlen,buffer)
Let hash = nsmutablestring()
for i in 0.. < Digestlen {
Hash.appendformat ("%02x", Buffer[i])
}
Buffer. Dealloc (Digestlen)
return String (Format:hash as String)
}
Third-party access to the small note