{"id":34905144,"url":"https://github.com/alistanis/goenc","last_synced_at":"2025-12-26T10:00:05.933Z","repository":{"id":57489258,"uuid":"83084142","full_name":"alistanis/goenc","owner":"alistanis","description":"Encryption and Decryption functions for Go made easy. Encryption should be as simple as calling Encrypt(key, data) and Decrypt(key, data).","archived":false,"fork":false,"pushed_at":"2017-03-12T18:20:44.000Z","size":79,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-13T23:37:17.533Z","etag":null,"topics":["easy","easy-to-use","encryption","go","golang","networking","simple","simple-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alistanis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-24T21:27:30.000Z","updated_at":"2024-12-13T14:20:27.000Z","dependencies_parsed_at":"2022-08-29T22:11:48.485Z","dependency_job_id":null,"html_url":"https://github.com/alistanis/goenc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alistanis/goenc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alistanis%2Fgoenc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alistanis%2Fgoenc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alistanis%2Fgoenc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alistanis%2Fgoenc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alistanis","download_url":"https://codeload.github.com/alistanis/goenc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alistanis%2Fgoenc/sbom","scorecard":{"id":184546,"data":{"date":"2025-08-11","repo":{"name":"github.com/alistanis/goenc","commit":"811459a68eccfec81fc4a0dd33ed493e8861417a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"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":"Code-Review","score":0,"reason":"Found 0/30 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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"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"}},{"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: ISC License: 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"}}]},"last_synced_at":"2025-08-16T19:32:29.256Z","repository_id":57489258,"created_at":"2025-08-16T19:32:29.256Z","updated_at":"2025-08-16T19:32:29.256Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28052416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["easy","easy-to-use","encryption","go","golang","networking","simple","simple-api"],"created_at":"2025-12-26T10:00:03.887Z","updated_at":"2025-12-26T10:00:05.918Z","avatar_url":"https://github.com/alistanis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goenc\n[![Go Report Card](https://goreportcard.com/badge/github.com/alistanis/goenc)](https://goreportcard.com/report/github.com/alistanis/goenc)\n[![GoDoc](https://godoc.org/github.com/alistanis/goenc?status.svg)](https://godoc.org/github.com/alistanis/goenc)\n[![codecov](https://codecov.io/gh/alistanis/goenc/branch/master/graph/badge.svg)](https://codecov.io/gh/alistanis/goenc)\n\nEncryption and Decryption functions for Go made easy. Encryption should be as simple as calling Encrypt(key, data) and Decrypt(key, data).\n\n###Note: I am in the process of trying to get this reviewed - use at your own risk\n\n# API\n\nThe API is built around the `BlockCipher` interface and the `Session` struct.\n\n`BlockCipher` can be used to encrypt simple messages or small files. \n\n```go\n// BlockCipher represents a cipher that encodes and decodes chunks of data at a time\ntype BlockCipher interface {\n\tEncrypt(key, plaintext []byte) ([]byte, error)\n   \tDecrypt(key, ciphertext []byte) ([]byte, error)\n   \tKeySize() int\n}\n```\n\n`Session` can be used to perform key exchanges and send secure messages over a \"channel\" (`io.ReadWriter`)\nIt also natively performs key derivation, can handle key exchanges, and can prevent replay attaacks. // that is a joke\n\n###Note: Session has been temporarily removed in order to author a more secure version.\n\n```go\n// Session represents a session that can be used to pass messages over a secure channel\ntype Session struct {\n   \tCipher   *Cipher\n   \tChannel\n   \tlastSent uint32\n   \tlastRecv uint32\n   \tsendKey  *[32]byte\n   \trecvKey  *[32]byte\n}\n```\n\nAll internal packages implement the `BlockCipher` interface with a `Cipher` struct, allowing for flexibility when working with the `BlockCipher` interface.\n\nEach package can also be used directly, as the `Cipher` struct in each simply wraps public functions.\n\nThis package supports the following types of encryption, all using the Go stdlib with exception for NaCL, which uses [Secretbox from the /x/crypto package](https://godoc.org/golang.org/x/crypto/nacl/secretbox):\n\n---\n* AES-CBC\n* AES-CFB\n* AES-CTR \n* AES-GCM\n* NaCL - with a user provided pad\n\n\n* ####All types support encryption + authentication\n\n---\n\n#####Example Usage of package functions\n    \n```go\nkey := []byte(\"some 32 byte key\") // obviously this would fail without being 32 bytes\nciphertext, err := gcm.Encrypt(key, []byte(\"super secret message\"))\nif err != nil {\n    return err\n}\nplaintext, err := gcm.Decrypt(key, ciphertext)\nif err != nil {\n    return err  \n}\nfmt.Println(plaintext) // super secret message\n```       \n#####Example Usage of the main Cipher struct and a BlockCipher interface - this will perform key derivation\n\n```go\nc, err := goenc.NewCipher(goenc.CBC, goenc.InteractiveComplexity)\nif err != nil {\n    return err\n}\nciphertext, err := c.Encrypt(key, []byte(\"super secret message\"))\nif err != nil {\n    return err       \n}\nplaintext, err := c.Decrypt(key, ciphertext)\nif err != nil {\n    return err\n}    \nfmt.Println(plaintext) // super secret message\n```\n    \n#####Example Usages of Session\n\nNote: Retries and connection breaking are not shown here\n\n######As a server   \n\n```go\n// wait until a client connects and performs a key exchange\ns, err := goenc.Listen(readWriter, cipher)\n// if exchange is bad or none was given, we return\nif err != nil {\n    return err\n}\n\n// s is now a session on the given readWriter (underlying conn) and can wait to receive messages\nfor {\n    msg, err := s.Receive()\n    is err != nil {\n        // check for closed connection here and break if it is (not shown)\n        someErrChan \u003c- err\n        continue\n    }\n    \n    msg, err := someMsgParsingFunc(msg)\n    if err != nil {\n        // garbled message\n        someErrChan \u003c- err\n        continue\n    }\n    \n    switch msg.Type {\n        case SomeCoolThing:\n            err = s.Send(someConstMessage)\n            if err != nil {\n                someErrChan \u003c- err\n            }\n        default:\n            // successfully parsed but we don't know what to do, probably retry parsing\n    }\n}\n```\n\n######As a client\n\n```go    \n// initial connection to underlying conn of readWriter\ns, err := goenc.Dial(readWriter, cipher)\nif err != nil {\n    return err\n}\n\n// send an initial message\nerr := s.Send(someMessage)\n        is err != nil {\n            return err\n        }\nfor {\n       \n        // wait for response\n        msg, err := s.Receive()\n        if err != nil {\n            someErrChan \u003c- err\n            continue\n        }\n        \n        msg, err = someMsgParsingFunc(msg)\n        if err != nil {\n            // garbled message\n            someErrChan \u003c- err\n            continue\n        }\n        \n        switch msg.Type {\n            case SomeCoolThing:\n                err = s.Send(someConstMessage)\n                if err != nil {\n                    someErrChan \u003c- err\n                }\n            default:\n                // successfully parsed but we don't know what to do, probably retry parsing\n        }\n    }\n```\n\n#SSH Package\n\nThe ssh package contains convenience functions for generating and parsing ssh keys. They are a wrapper around the /x/crypto package's ssh package.\n\nTODO\n---\n```\n1. [ ] Get project reviewed (if you are a security expert interested in reviewing this, please contact me and let me know if you find anything)\n2. [ ] More complete documentation with examples\n    *  [ ] Document full examples of package functions and the small differences they have\n    *  [ ] Document SenderID functions in the GCM package and give a real world example\n3. [ ] Implement SenderID functions in packages other than GCM\n4. [ ] Give user level control over when/how key derivation takes place\n    *  The way it works now on a session is that the key will be derived for every message - this is slow, but potentially more secure\n       * If one algo has a flaw in which a prior key is discovered, only that message could be read\n       * That should still be left up to the user\n    *  [ ] Allow user given salt   \n```        \n        \n#Special Thanks\n\nA very special thanks to [Kyle Isom](https://github.com/kisom), whose book provided a very good jumping off point for starting this library.\n\nYou can find his book here: [Practical Cryptography with Go](https://leanpub.com/gocrypto/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falistanis%2Fgoenc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falistanis%2Fgoenc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falistanis%2Fgoenc/lists"}