现在的位置: 首页 > 综合 > 正文

go语言使用crc32得到网络消息的校验码

2013年10月12日 ⁄ 综合 ⁄ 共 264字 ⁄ 字号 评论关闭
package main

import (
"fmt"
"hash/crc32"
"io")

func main(){
	//hash := crc32.NewIEEE()
	
	check_str := "Discard medicine more than two years old."
	//hash.write(check_str)
	//hash.Sum()
	ieee := crc32.NewIEEE()
	io.WriteString(ieee, check_str)
	
	s := ieee.Sum32()	
	fmt.Println("IEEE(%s) = 0x%x",check_str,s)

}

抱歉!评论已关闭.