(h hash.Hash)
| 95 | } |
| 96 | |
| 97 | func GetSha1Status(h hash.Hash) []byte { |
| 98 | if reflect.TypeOf(h).String() != "*sha1.digest" { |
| 99 | return nil |
| 100 | } |
| 101 | result := make([]byte, 20) |
| 102 | // 反射大法好 |
| 103 | s := reflect.ValueOf(h).Elem().Field(0) |
| 104 | for i := 0; i < 5; i++ { |
| 105 | binary.LittleEndian.PutUint32(result[i*4:], uint32(s.Index(i).Uint())) |
| 106 | } |
| 107 | return result |
| 108 | } |
no test coverage detected