Golang's MD5 encryption. base64 decrypts the guid code:
/*** Used for encryption and decryption (including MD5 encryption and base64 encryption/Decryption) and guid generation time: * zhifieya */package safeimport ("crypto/MD5" "crypto/Rand" "crypto/sha1" "encoding/base64" "encoding/Hex" "Io" "strings ") const (// base64 partition table, do not have repeated base64table = "<> :;',. /[email protected] # $ cdvwx % ^ & * abyzabcghijklmnopqrstuvwxyz01efghijklmnopqrstu2345678 (DEF) _ + | {} [] 9/"hashfunctionheader =" Zh. ife. iya "hashfunctionfooter =" 09. o25.o000078 ")/*** Character string for MD5 encryption, cannot decrypt */func getmd5string (s string) string {H: = md5.new () H. write ([] Byte (s) // use zhifeiya name for hash value. Do not change return hex after setting. encodetostring (H. sum (NiL)}/* Get sha1 string */func getsha1string (s string) string {T: = sha1.new () T. write ([] Byte (s) return hex. encodetostring (T. sum (NiL)}/*** get a guid value */func getguid () string {B: = make ([] Byte, 48) If _, err: = Io. readfull (Rand. reader, B); Err! = Nil {return ""} return getmd5string (base64.urlencoding. encodetostring (B)} var coder = base64.newencoding (base64table)/*** base64 encryption */func base64encode (STR string) string {var SRC [] Byte = [] Byte (hashfunctionheader + STR + hashfunctionfooter) return string ([] Byte (coder. encodetostring (SRC)}/*** base64 decryption */func base64decode (STR string) (string, error) {var SRC [] Byte = [] Byte (STR) by, err: = coder. decodestring (string (SRC) return strings. replace (strings. replace (string (by), hashfunctionheader, "",-1), hashfunctionfooter, "",-1), err}
Golang encryption, decryption, and small guid Method