registry.go 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. package multihash
  2. import (
  3. "hash"
  4. mhreg "github.com/multiformats/go-multihash/core"
  5. _ "github.com/multiformats/go-multihash/register/all"
  6. _ "github.com/multiformats/go-multihash/register/miniosha256"
  7. )
  8. // Register is an alias for Register in the core package.
  9. //
  10. // Consider using the core package instead of this multihash package;
  11. // that package does not introduce transitive dependencies except for those you opt into,
  12. // and will can result in smaller application builds.
  13. func Register(indicator uint64, hasherFactory func() hash.Hash) {
  14. mhreg.Register(indicator, hasherFactory)
  15. }
  16. // Register is an alias for Register in the core package.
  17. //
  18. // Consider using the core package instead of this multihash package;
  19. // that package does not introduce transitive dependencies except for those you opt into,
  20. // and will can result in smaller application builds.
  21. func GetHasher(indicator uint64) (hash.Hash, error) {
  22. return mhreg.GetHasher(indicator)
  23. }
  24. // DefaultLengths maps a multihash indicator code to the output size for that hash, in units of bytes.
  25. var DefaultLengths = mhreg.DefaultLengths