Skip to content

Commit 82aec37

Browse files
committed
Deprecate bitarray.Hash().
1 parent 37456bf commit 82aec37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

bitarray.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ func (ba *BitArray) BitAt(off int) byte {
240240
// single byte 0xf0. In order to prevent these from being mapped to the same
241241
// hash value, the hash is calculated after appending a 3 bits marker
242242
// indicating the number of padding LSBs at the end of the original bit array.
243+
//
244+
// Deprecated: Most hash functions can handle bit-oriented messages as-is by
245+
// design, and it is not appropriate to use the byte-oriented standard hash.Hash
246+
// with padding bits. The result does not comply with the specifications. Not
247+
// all hash functions are available, but for SHA-1 and SHA-2, which can handle
248+
// bit-oriented messages correctly, dedicated methods such as SHA512, SHA256,
249+
// and SHA1 are now available. It is better to use them instead.
243250
func (ba *BitArray) Hash(h hash.Hash) []byte {
244251
b, _ := ba.MarshalBinary()
245252
h.Write(b)

0 commit comments

Comments
 (0)