{"id":38633580,"url":"https://github.com/schigh/str","last_synced_at":"2026-01-17T09:01:40.414Z","repository":{"id":57483131,"uuid":"87193228","full_name":"schigh/str","owner":"schigh","description":"The missing Golang Strings Library","archived":false,"fork":false,"pushed_at":"2017-07-15T18:39:31.000Z","size":23,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-17T16:05:57.149Z","etag":null,"topics":["currency","golang","hmac","pad","sha1","sha256","strings","token","wordwrap"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schigh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-04T13:57:45.000Z","updated_at":"2024-08-06T19:43:28.000Z","dependencies_parsed_at":"2022-08-27T20:02:47.714Z","dependency_job_id":null,"html_url":"https://github.com/schigh/str","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/schigh/str","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fstr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fstr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fstr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fstr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schigh","download_url":"https://codeload.github.com/schigh/str/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schigh%2Fstr/sbom","scorecard":{"id":803915,"data":{"date":"2025-08-11","repo":{"name":"github.com/schigh/str","commit":"361193c512d28630d4ba9df72c2852b88c273cba"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/16 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":"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":"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":"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":"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":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T11:16:01.555Z","repository_id":57483131,"created_at":"2025-08-23T11:16:01.555Z","updated_at":"2025-08-23T11:16:01.555Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"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":["currency","golang","hmac","pad","sha1","sha256","strings","token","wordwrap"],"created_at":"2026-01-17T09:01:29.912Z","updated_at":"2026-01-17T09:01:40.390Z","avatar_url":"https://github.com/schigh.png","language":"Go","readme":"[![Build Status](https://travis-ci.org/schigh/str.svg?branch=master)](https://travis-ci.org/schigh/str)\n[![GoDoc](https://godoc.org/github.com/schigh/str?status.svg)](https://godoc.org/github.com/schigh/str)\n[![Go Report Card](https://goreportcard.com/badge/github.com/schigh/str)](https://goreportcard.com/report/github.com/schigh/str)\n\n\n# str\nThe missing Golang Strings Library\n\nstr makes some common string tasks a little simpler, so you can get on with writing your applications.\n\n#### Overview\n\nMany of these functions serve as Go analogues to some of the better PHP string \nfunctions (yes, they do exist).\n\nSome things of note:\n* All functions output a single string.\n    * If an error is encountered, or if a function cannot do its job, it outputs an empty string.\n* There are no dependencies other than elements from the standard library\n\n\n#### Usage\n\n```go\nimport \"github.com/schigh/str\"\n```\n##### Pad\nPads a string left or right, similar to PHP's `str_pad`\n```go\nsku := str.Pad(\"1234\", \"0\", 8, str.PadLeft)\n// 00001234\n```\nYour pad string may be longer than one character\n```go\nid := str.Pad(\"1234\", \"ABC\", 12, str.PadRight)\n// 1234ABCABCABC\n```\nNote that for multi-character pads, if the padding doesn't land cleanly at the desired length, `str.Pad` will overshoot the desired length until the padding is complete.\n\n\n##### Substring\nGets a substring from a string.\n```go\nmonth := str.Substring(\"2017-04-24\", 5, 2)\n// 04\n\nday := str.Substring(\"2017-04-24\", -2, 2)\n// 24\n```\nYou can use a negative value for the start, which, like PHP's [`substr`](http://us3.php.net/manual/en/function.substr.php) function, will pull from the back of the source string.\n\n###### Pad\nPads a string with another string.  This behavior is similar to PHP's [`str_pad`](http://php.net/manual/en/function.str-pad.php)\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/schigh/str\"\n)\n\nvar partialNum = \"1234\"\n\nfunc main() {\n    fmt.Println(str.Pad(partialNum, \"0\", 8, str.PadLeft))\n    // prints 00001234\n    \n    fmt.Println(str.Pad(partialNum, \"0\", 8, str.PadRight))\n    // prints 12340000\n    \n    fmt.Println(str.Pad(partialNum, \"abcd\", 8, str.PadLeft))\n    // prints abcd1234\n    \n    fmt.Println(str.Pad(partialNum, \"abcd\", 10, str.PadLeft))\n    // prints abcdabcd1234\n    \n    // The pad will be repeated at least until the length is satisfied.  \n    // In some cases, like above, it will overshoot.  \n    // It will NEVER undershoot \n}\n```\n\n###### Substring\nGets a substring from a string.  This behavior is similar to PHP's [`substr`](http://php.net/manual/en/function.substr.php)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nvar slug = \"1234567890\"\n\nfunc main() {\n\tfmt.Println(str.Substring(slug, 0, 3))\n\t// prints 123\n\t\n\tfmt.Println(str.Substring(slug, 1, 3))\n\t// prints 234\n\t\n\tfmt.Println(str.Substring(slug, -3, 3))\n\t// prints 890\n\t\n\tfmt.Println(str.Substring(slug, -1, 3))\n\t// nonsense call, this prints 0\n\t\n\tfmt.Println(str.Substring(slug, -11, 3))\n\t// out of range, prints empty string\n}\n```\n\n###### MD5\nReturns the MD5 hash (hex-encoded string) of a supplied string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n    fmt.Println(str.MD5(\"我爱“走”\"))\n    // prints 502d97cf15ded2b612eb7caf580440a5\n}\n```\n\n###### SHA1\nReturns the SHA1 hash (hex-encoded string) of a supplied string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n    fmt.Println(str.SHA1(\"我爱“走”\"))\n    // prints ca23c160bcf89334a83bcad027c136381bf8cc2b\n}\n```\n\n###### SHA256\nReturns the SHA256 hash (hex-encoded string) of a supplied string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n    fmt.Println(str.SHA256(\"我爱“走”\"))\n    // prints 6ce570942bcdd21116e930a66dd59cfbf23b075d1796d87e93951de43fabae4b\n}\n```\n\n###### HMAC\nReturns the HMAC digest (hex-encoded) of a string with supplied options\n\n_Note_:\n\nIf you don't set the default HMAC signing key, one will be generated for you, based on the hardware\naddress of the first network interface the program finds.\n\nThis is **not** meant to replace the security of a strong signing key, but it is better than nothing.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nvar superSecretKey = \"ILIKETURTLES!!!1\"\n\nfunc main() {\n\toptions := \u0026str.HMACOptions{\n\t\tKeyData: []byte(superSecretKey),\n\t\tDigestType: str.HMACDigestTypeSHA256, // see hmac.go for digest types\n\t}\n\t\n\t// This will set the HMAC options globally\n\tstr.SetHMACOptions(options)\n\tfmt.Println(str.HMAC(\"我爱“走”\"))\n\t// prints 271b03817aa1bea17b1ef447eec434751fb71d5b6273324fc181c10b18e61463\n\t\n\t// you can also just call HMACWithOptions directly\n\tfmt.Println(str.HMACWithOptions(\"我爱“走”\", options))\n\t// prints 271b03817aa1bea17b1ef447eec434751fb71d5b6273324fc181c10b18e61463\n}\n```\n\n###### CRC32\nReturns the Cyclic Redundancy Check (CRC) 32-bit checksum of a string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n\toptions := \u0026str.CRC32Options{\n\t\tPolynomialType: str.CRC32TypeK, // see crc32.go for polynomial types\n\t}\n\t\n\t// This will set the CRC32 options globally\n\tstr.SetCRC32Options(options)\n\tfmt.Println(str.CRC32(\"我爱“走”\"))\n\t// prints 2845165967\n\t\n\t// you can also just call HMACWithOptions directly\n\tfmt.Println(str.CRC32WithOptions(\"我爱“走”\", options))\n\t// prints 2845165967\n}\n```\n\n###### CRC64\nReturns the Cyclic Redundancy Check (CRC) 64-bit checksum of a string.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n\toptions := \u0026str.CRC64Options{\n\t\tPolynomialType: str.CRC64TypeISO, // see crc64.go for polynomial types\n\t}\n\t\n\t// This will set the CRC64 options globally\n\tstr.SetCRC64Options(options)\n\tfmt.Println(str.CRC64(\"我爱“走”\"))\n\t// prints 17267613643596219338\n\t\n\t// you can also just call HMACWithOptions directly\n\tfmt.Println(str.CRC64WithOptions(\"我爱“走”\", options))\n\t// prints 17267613643596219338\n}\n```\n\n###### Wrap\nReturns a string that is wrapped according to a specified behavior.  The wrap is delimited by a specified string (default is '\\n')\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nvar longSentence = `This is a string that could very likely be broken up into more than one line.  Maybe we should do that.  Just a thought.`\n\nfunc main() {\n\toptions := \u0026str.WrapOptions{\n\t\tWidth: 24,\n\t\tLineBreak: \"\\n\",\n\t\tBehavior: str.WrapAfterWord, // wrap after a word if it extends past line length\n\t}\n\t\n\t// set wordwrap options globally\n\tstr.SetWrapOptions(options)\n\t\n\tfmt.Println(str.Wrap(longSentence))\n\t/*\n\tprints:\n\tThis is a string that could\n\tvery likely be broken up\n\tinto more than one line.\n\tMaybe we should do that.\n\tJust a thought.\n\t*/\n\t\n\toptions = \u0026str.WrapOptions{\n\t\tWidth: 24,\n\t\tLineBreak: \"\\n\",\n\t\tBehavior: str.WrapBeforeWord, // wrap before the word if it will extend past the line length\n\t}\n\t\n\tfmt.Println(str.WrapWithOptions(longSentence, options))\n\t/*\n\tprints:\n\tThis is a string that\n\tcould very likely be\n\tbroken up into more than\n\tone line. Maybe we\n\tshould do that. Just a\n\tthought.\n\t*/\n\t\n\toptions = \u0026str.WrapOptions{\n\t\tWidth: 24,\n\t\tLineBreak: \"\\n\",\n\t\tBehavior: str.WrapLiteral, // wrap exactly at the line length, do not trim whitespace (this is good for base64-encoded lines e.g. RFC 4648)\n\t}\n\t\n\tfmt.Println(str.WrapWithOptions(longSentence, options))\n\t/*\n\tprints\n\tThis is a string that co\n\tuld very likely be broke\n\tn up into more than one \n\tline. Maybe we should do\n\t that. Just a thought.\n\t*/\n}\n```\n\n###### Token\nReturns a token based generated from user options\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/schigh/str\"\n)\n\nfunc main() {\n\tfmt.Println(str.Token())\n\t// prints default format token that matches ^[a-zA-Z0-9]{20}$\n\t// ex: 7wyxEyzgvsrEGdHcpbiU\n\t\n\toptions := \u0026str.TokenOptions{\n\t\tLength: 32,\n\t\tCharset: `10`,\n\t\tPrefix: ``,\n\t}\n\t\n\tstr.SetTokenOptions(options)\n\tfmt.Println(str.Token())\n\t// prints something like 00011110000110010100011010011111\n\t\n\toptions = \u0026str.TokenOptions{\n\t\tLength: 6,\n\t\tCharset: `abcdef1234567890`,\n\t\tPrefix: `#`,\n\t}\n\tfmt.Println(str.TokenWithOptions(options))\n\t// prints something like #cb4db\n}\n```","funding_links":[],"categories":["Miscellaneous","Microsoft Office"],"sub_categories":["Strings"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschigh%2Fstr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschigh%2Fstr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschigh%2Fstr/lists"}