-
-
Save holys/20f7efa17b5cb3f83756 to your computer and use it in GitHub Desktop.
xiaomi oauth signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/hmac" | |
"crypto/sha1" | |
"encoding/base64" | |
"fmt" | |
"io" | |
"net/url" | |
) | |
func main() { | |
sign_string := "this is sign string" | |
mac_key := "this is mac key" | |
m := hmac.New(sha1.New, []byte(mac_key)) | |
io.WriteString(m, sign_string) | |
// sign := fmt.Sprintf("%x", m.Sum(nil)) | |
// fmt.Println(sign) | |
h := base64.StdEncoding.EncodeToString(m.Sum(nil)) | |
fmt.Println(url.QueryEscape(h)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/hmac" | |
"crypto/sha1" | |
"encoding/base64" | |
"fmt" | |
"io" | |
"net/url" | |
) | |
func main() { | |
sign_string := "this is sign string" | |
mac_key := "this is mac key" | |
m := hmac.New(sha1.New, []byte(mac_key)) | |
io.WriteString(m, sign_string) | |
// sign := fmt.Sprintf("%x", m.Sum(nil)) | |
// fmt.Println(sign) | |
h := base64.StdEncoding.EncodeToString(m.Sum(nil)) | |
fmt.Println(url.QueryEscape(h)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment