sha1_keyed_mac.go (511B)
1 package main 2 3 import ( 4 "bufio" 5 "fmt" 6 "os" 7 "./sha_1" 8 ) 9 10 func main() { 11 if len(os.Args) > 2 { 12 key := []byte(os.Args[1]) 13 msg := []byte(os.Args[2]) 14 fmt.Printf("%xn", sha_1.Sum(append(key, msg...))) 15 } else if len(os.Args) == 2 { 16 msg := []byte(os.Args[1]) 17 fmt.Printf("%xn", sha_1.Sum(msg)) 18 //af 06 49 23 bb f2 30 15 96 aa c4 c2 73 ba 32 17 8e bc 4a 96 19 } else { 20 msg, _ := bufio.NewReader(os.Stdin).ReadString('n') 21 m := []byte(msg[:len(msg) - 1]) 22 fmt.Printf("%xn", sha_1.Sum(m)) 23 } 24 }