FromBytes digests the input and returns a Digest.
(p []byte)
| 156 | |
| 157 | // FromBytes digests the input and returns a Digest. |
| 158 | func (a Algorithm) FromBytes(p []byte) Digest { |
| 159 | digester := a.Digester() |
| 160 | |
| 161 | if _, err := digester.Hash().Write(p); err != nil { |
| 162 | // Writes to a Hash should never fail. None of the existing |
| 163 | // hash implementations in the stdlib or hashes vendored |
| 164 | // here can return errors from Write. Having a panic in this |
| 165 | // condition instead of having FromBytes return an error value |
| 166 | // avoids unnecessary error handling paths in all callers. |
| 167 | panic("write to hash function returned error: " + err.Error()) |
| 168 | } |
| 169 | |
| 170 | return digester.Digest() |
| 171 | } |
| 172 | |
| 173 | // FromString digests the string input and returns a Digest. |
| 174 | func (a Algorithm) FromString(s string) Digest { |