JSON MD5 of Golang language

Source: Internet
Author: User
Package Mainimport ("Encoding/json"//JSON Tool "FMT")//github.com/pquerna/ffjson/ffjson//this JSON tool is much more efficient than its own JSON /and interface, exactly, type worker struct {Name string ' JSON: ' worker_name '///Convert to JSON format, key is Worker_name Sex string sal ay int32//Note that JSON does not operate on this property because Salay is lowercase}func main () {///1, array form, encoded by x: = [5]int{1, 2, 3, 4, 5} bytes, E: = JSO N.marshal (x) if E! = nil {panic (e)} fmt. Println (String (bytes))//[1,2,3,4,5]//2, for map type, json var stu = map[string]string{} stu = Make (Map[string]stri NG) stu["name"] = "Beijing" Stujson, err: = json. Marshal (stu) if err! = Nil {panic (err)} FMT.        Println (String (Stujson))//{"name": "Beijing"}//3, JSON-encoded struct object wk: = worker{Name: "Xiaozhang", Sex: "Male", salay:34,} wrjson, ERR2: = json. Marshal (wk) if err2! = nil {panic (ERR2)} fmt. Println (String (Wrjson))//{"Worker_name": "Xiaozhang", "Sex": "Male"}//4, Solution to WrjsonCode var w interface{}//Declare a interface to store the decoded value JSON. Unmarshal (Wrjson, &w) fmt. PRINTF ("---JSON format decoding---->%v", W)//map[worker_name:xiaozhang Sex:male]}
==================================  
package mainimport (    "crypto/md5"    "fmt")//注意,md5是不逆的//md5的格式,基本上是一样的//使用时,按照下面的格式,copy就可以了。func main() {    Md5Inst := md5.New()    Md5Inst.Write([]byte("admin"))    Result := Md5Inst.Sum([]byte(""))    fmt.Printf("%x\n\n", Result)}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.