Created
August 31, 2015 23:53
-
-
Save yifan-gu/622a7057a652a568476f to your computer and use it in GitHub Desktop.
bcrypt
This file contains hidden or 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 ( | |
"fmt" | |
"golang.org/x/crypto/bcrypt" | |
) | |
func main() { | |
token, err := bcrypt.GenerateFromPassword([]byte("Cac3j5M0hvRRagKoVhk_v8DSMWit6gkyGQZ_5rMSMPxiJ_-QjWxPHT_YDXol7eNyiWusdhBn2weQLqlD2h84HA=="), bcrypt.DefaultCost) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println("token:", string(token)) | |
fmt.Println("compare result:", bcrypt.CompareHashAndPassword(token, []byte("Cac3j5M0hvRRagKoVhk_v8DSMWit6gkyGQZ_5rMSMPxiJ_-QjWxPHT_YDXol7eNyiWusdhBn2weQLqlD2h84HA==randombits!!!!!!!!!!"))) | |
} | |
Author
yifan-gu
commented
Aug 31, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment