{"id":21560418,"url":"https://github.com/icza/huffman","last_synced_at":"2026-03-10T13:35:00.138Z","repository":{"id":57505913,"uuid":"60238883","full_name":"icza/huffman","owner":"icza","description":"Huffman coding implementation in Go (Huffman tree, Symbol table, Huffman Reader + Writer).","archived":false,"fork":false,"pushed_at":"2023-03-30T13:38:29.000Z","size":93,"stargazers_count":31,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T12:17:39.041Z","etag":null,"topics":["huffman-coding","huffman-reader","huffman-tree","huffman-writer","symbol-table"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"icza"}},"created_at":"2016-06-02T06:38:32.000Z","updated_at":"2025-03-02T22:56:20.000Z","dependencies_parsed_at":"2024-06-18T22:35:13.598Z","dependency_job_id":"7d47618a-e82d-45e0-bbc3-2b60da5b93f1","html_url":"https://github.com/icza/huffman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/icza/huffman","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fhuffman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fhuffman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fhuffman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fhuffman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icza","download_url":"https://codeload.github.com/icza/huffman/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icza%2Fhuffman/sbom","scorecard":{"id":480777,"data":{"date":"2025-08-11","repo":{"name":"github.com/icza/huffman","commit":"d543610fbdd249ba3a0180894032dc2872bfd128"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/icza/huffman/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/icza/huffman/go.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T16:33:55.317Z","repository_id":57505913,"created_at":"2025-08-19T16:33:55.317Z","updated_at":"2025-08-19T16:33:55.317Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30334713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["huffman-coding","huffman-reader","huffman-tree","huffman-writer","symbol-table"],"created_at":"2024-11-24T09:14:20.788Z","updated_at":"2026-03-10T13:35:00.088Z","avatar_url":"https://github.com/icza.png","language":"Go","readme":"# huffman\n\n![Build Status](https://github.com/icza/huffman/actions/workflows/go.yml/badge.svg)\n[![Go Reference](https://pkg.go.dev/badge/github.com/icza/huffman.svg)](https://pkg.go.dev/github.com/icza/huffman)\n[![Go Report Card](https://goreportcard.com/badge/github.com/icza/huffman)](https://goreportcard.com/report/github.com/icza/huffman)\n[![codecov](https://codecov.io/gh/icza/huffman/branch/master/graph/badge.svg)](https://codecov.io/gh/icza/huffman)\n\n[Huffman coding](https://en.wikipedia.org/wiki/Huffman_coding) implementation in Go\n(Huffman tree, Symbol table, Huffman Reader + Writer).\n\n### Huffman Tree\n\nUse the `Build()` function to build a Huffman tree. Use the `Print()` function to print Huffman codes\nof all leaves of a tree (for verification).\n\nExample:\n\n\tleaves := []*Node{\n\t\t{Value: ' ', Count: 20},\n\t\t{Value: 'a', Count: 40},\n\t\t{Value: 'm', Count: 10},\n\t\t{Value: 'l', Count: 7},\n\t\t{Value: 'f', Count: 8},\n\t\t{Value: 't', Count: 15},\n\t}\n\troot := Build(leaves)\n\tPrint(root)\n\nOutput:\n\n\t'a': 0\n\t'm': 100\n\t'l': 1010\n\t'f': 1011\n\t't': 110\n\t' ': 111\n\n### Huffman Reader and Writer\n\n[![GoDoc](https://godoc.org/github.com/icza/huffman/hufio?status.svg)](https://godoc.org/github.com/icza/huffman/hufio)\n\nThe `hufio` package implements a Huffman `Reader` and `Writer`. You may use these to transmit Huffman code of your data.\n\nThis `Reader` and `Writer` internally manages a Symbol Table (the frequency of encountered symbols, updated dynamically).\nThe `Writer` computes and sends the Huffman code of the data, the `Reader` receives the Huffman code and \"reconstructs\"\nthe original data based on that.\n\nThe implementation uses a _sliding window_ which is used to manage the symbol table.\nThe sliding window is optional, that is, if no window is used, the symbol table is calculated based on\nall previously encountered symbols.\n\n`Writer` + `Reader` example:\n\n\tbuf := \u0026bytes.Buffer{}\n\tw := NewWriter(buf)\n\tif _, err := w.Write([]byte(\"Testing Huffman Writer + Reader.\")); err != nil {\n\t\tlog.Panicln(\"Failed to write:\", err)\n\t}\n\tif err := w.Close(); err != nil {\n\t\tlog.Panicln(\"Failed to close:\", err)\n\t}\n\n\tr := NewReader(bytes.NewReader(buf.Bytes()))\n\tif data, err := ioutil.ReadAll(r); err != nil {\n\t\tlog.Panicln(\"Failed to read:\", err)\n\t} else {\n\t\tlog.Println(\"Read:\", string(data))\n\t}\n","funding_links":["https://github.com/sponsors/icza"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficza%2Fhuffman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficza%2Fhuffman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficza%2Fhuffman/lists"}