Skip to content

Add encoding.HexDecode/EncodeΒ #15068

Closed
Closed

Description

@bep

See #15060 (comment)

It's clumsy that you need to create a resource (making up an unique filename) to get a SRI hash.

I suggest we add crypto.Fingerprint with a similar signature to https://gohugo.io/functions/resources/fingerprint/

hash.Fingerprint [ALGORITHM] any -> string

The function name is a little clumsy, but we need to keep the two very similar functions in line.

Where any typically is a string (but can also be a Resource -- we have similar unwrappers elsewhere).

It would then return e.g. sha256-Yuh...rfE=.

Note to implementer: There's some obvious code reuse potential here.

Activity

  1. added this to the v0.164.0 milestone on Jun 27, 2026
  2. self-assigned this
    on Jun 28, 2026
  3. changed the title [-]Add hash.Fingerprint[/-] [+]Add crypto.Fingerprint[/+] on Jun 28, 2026
  4. bep commented on Jun 28, 2026

    @bep
    MemberAuthor

    I changed my mind about this one. Having multiple special purpose funcs that's almost the same isn't a great thing. Instead I suggest we add encoding.HexDecode (and encoding.HexEncode for completeness), so we can do:

    {{ $hash := $s | crypto.SHA256 | encoding.HexDecode | encoding.Base64Encode }}
    {{ $sri := printf "sha256-%s" $hash }}
  5. changed the title [-]Add crypto.Fingerprint[/-] [+]Add encoding.HexDecode/Encode[/+] on Jun 28, 2026
  6. added 5 commits that reference this issue on Jun 28, 2026
    1e8e922
    00b0c0f
    74967cf
    2529325
    e8ea3d3
  7. added a commit that references this issue on Jun 28, 2026
    a5ec542
  8. github-actions commented on Sep 2, 2026

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  9. locked as resolved and limited conversation to collaborators on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions