{"id":36419289,"url":"https://github.com/kcrypt/scala-sha","last_synced_at":"2026-01-11T17:02:47.711Z","repository":{"id":39789096,"uuid":"385053316","full_name":"kcrypt/scala-sha","owner":"kcrypt","description":"SHA and Shake for scala","archived":false,"fork":false,"pushed_at":"2025-12-14T01:14:12.000Z","size":247,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T22:59:30.854Z","etag":null,"topics":["scala","scala-js","scala-native","sha1","sha2","sha3","shake"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kcrypt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"docs/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-11T21:14:29.000Z","updated_at":"2025-12-14T01:14:16.000Z","dependencies_parsed_at":"2024-03-30T23:27:57.021Z","dependency_job_id":"ca270cd2-dc9b-49fc-a41f-03b6f9a64a88","html_url":"https://github.com/kcrypt/scala-sha","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/kcrypt/scala-sha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcrypt%2Fscala-sha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcrypt%2Fscala-sha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcrypt%2Fscala-sha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcrypt%2Fscala-sha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kcrypt","download_url":"https://codeload.github.com/kcrypt/scala-sha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kcrypt%2Fscala-sha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28314260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"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":["scala","scala-js","scala-native","sha1","sha2","sha3","shake"],"created_at":"2026-01-11T17:02:47.650Z","updated_at":"2026-01-11T17:02:47.704Z","avatar_url":"https://github.com/kcrypt.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SHA and Shake for scala\n\nThis is Secure Hash Algorithms family which is implemented for scala, scala-js\nand scala-native, without any dependencies.\n\nThis code base implements SHA-0, SHA-1, SHA-2 and SHA-3. Keep in mind that SHA-0\nis broken and I've implemented it just for fun :)\n\nThe propose of this code to be fast enough to hash something up to a few\nmegabytes at the worst case and at few kilobytes as usual case. Where? At any\nscala-based application where hashing isn't the bottleneck. This code hasn't got\nany CPU related optimizations, nor multithreading features for Keccak / SHA-3.\n\nIf you need very fast and secure hash function for scala I suggest to use\n[blake3](https://github.com/catap/scala-blake3) which is 3 time faster.\n\nYou can use it as\n```\nlibraryDependencies += \"pt.kcry\" %%% \"sha\" % \"x.x.x\"\n```\nThe latest version is ![maven-central]\n\nAPI is pretty simple and quite limited :)\n```\nscala\u003e import pt.kcry.sha._\nimport pt.kcry.sha._\n\nscala\u003e Sha2_256.hash(\"abc\".getBytes())\nval res1: Array[Byte] = Array(-70, 120, 22, -65, -113, 1, -49, -22, 65, 65, 64, -34, 93, -82, 34, 35, -80, 3, 97, -93, -106, 23, 122, -100, -76, 16, -1, 97, -14, 0, 21, -83)\n\nscala\u003e \n```\n\nYou may also create a new object from specified hash to `update` it, and at some\npoint `finish` it like this:\n```\nscala\u003e import pt.kcry.sha._\nimport pt.kcry.sha._\n\nscala\u003e val sha1 = new Sha1()\nval sha1: pt.kcry.sha.Sha1 = pt.kcry.sha.Sha1@1224e1b6\n\nscala\u003e sha1.update(\"abc\".getBytes(), 0, 2)\n\nscala\u003e sha1.update(\"abc\".getBytes(), 2, 1)\n\nscala\u003e val hashed = new Array[Byte](20)\nval hashed: Array[Byte] = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)\n\nscala\u003e sha1.finish(hashed, 0)\n\nscala\u003e hashed\nval res3: Array[Byte] = Array(-87, -103, 62, 54, 71, 6, -127, 106, -70, 62, 37, 113, 120, 80, -62, 108, -100, -48, -40, -99)\n\nscala\u003e \n```\n\nAll these objects aren't thread safe. After `finish` it should be treated as\nbroken.\n\nAnyway, I did a few benchmarks to compare this implementation with JVM one\nwhich was run on `JDK 11.0.11, OpenJDK 64-Bit Server VM, 11.0.11+9-LTS`:\n```\nBenchmark                 (len)  Mode  Cnt    Score   Error  Units\nShaBenchmark.jvmSha1       1024  avgt    5    3,686 ± 0,005  us/op\nShaBenchmark.jvmSha1      16384  avgt    5   55,556 ± 1,103  us/op\nShaBenchmark.jvmSha256     1024  avgt    5    4,326 ± 0,012  us/op\nShaBenchmark.jvmSha256    16384  avgt    5   61,924 ± 0,025  us/op\nShaBenchmark.jvmSha3_256   1024  avgt    5    4,129 ± 0,045  us/op\nShaBenchmark.jvmSha3_256  16384  avgt    5   61,627 ± 1,422  us/op\nShaBenchmark.jvmSha3_512   1024  avgt    5    7,974 ± 0,091  us/op\nShaBenchmark.jvmSha3_512  16384  avgt    5  111,711 ± 0,372  us/op\nShaBenchmark.jvmSha512     1024  avgt    5    3,172 ± 0,001  us/op\nShaBenchmark.jvmSha512    16384  avgt    5   44,205 ± 0,024  us/op\nShaBenchmark.sha1          1024  avgt    5    4,285 ± 0,002  us/op\nShaBenchmark.sha1         16384  avgt    5   64,380 ± 0,022  us/op\nShaBenchmark.sha256        1024  avgt    5    4,330 ± 0,005  us/op\nShaBenchmark.sha256       16384  avgt    5   63,293 ± 0,024  us/op\nShaBenchmark.sha3_256      1024  avgt    5    5,919 ± 0,019  us/op\nShaBenchmark.sha3_256     16384  avgt    5   84,952 ± 0,468  us/op\nShaBenchmark.sha3_512      1024  avgt    5    8,114 ± 0,078  us/op\nShaBenchmark.sha3_512     16384  avgt    5  118,706 ± 0,924  us/op\nShaBenchmark.sha512        1024  avgt    5    3,168 ± 0,007  us/op\nShaBenchmark.sha512       16384  avgt    5   44,630 ± 0,017  us/op\n```\nfor easy compare I've performed the same benchmark on blake3:\n\n```\nBenchmark                  (dataLen)  (hashLen)  Mode  Cnt   Score   Error  Units\nBlake3Benchmark.newHasher       1024        256  avgt    5   2,143 ± 0,037  us/op\nBlake3Benchmark.newHasher       1024        512  avgt    5   2,564 ± 0,019  us/op\nBlake3Benchmark.newHasher      16384        256  avgt    5  26,472 ± 0,023  us/op\nBlake3Benchmark.newHasher      16384        512  avgt    5  26,641 ± 0,131  us/op\n```\n\n[maven-central]: https://img.shields.io/maven-central/v/pt.kcry/sha_2.13?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcrypt%2Fscala-sha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkcrypt%2Fscala-sha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkcrypt%2Fscala-sha/lists"}