{"id":23764465,"url":"https://github.com/chaqchase/rscrypt","last_synced_at":"2026-03-22T22:30:16.820Z","repository":{"id":48521565,"uuid":"516926405","full_name":"chaqchase/rscrypt","owner":"chaqchase","description":"rscrypt is a simple, fast, and secure encryption tool written in Rust. [Based on sha256]","archived":false,"fork":false,"pushed_at":"2023-11-23T00:41:07.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T00:24:38.028Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://crates.io/crates/rscrypt","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chaqchase.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,"governance":null}},"created_at":"2022-07-23T01:12:46.000Z","updated_at":"2023-11-23T00:38:57.000Z","dependencies_parsed_at":"2023-11-23T01:40:42.766Z","dependency_job_id":"f48cd886-0042-4464-9dbc-d93f979f9814","html_url":"https://github.com/chaqchase/rscrypt","commit_stats":null,"previous_names":["chaqchase/rscrypt"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Frscrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Frscrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Frscrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Frscrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaqchase","download_url":"https://codeload.github.com/chaqchase/rscrypt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239938059,"owners_count":19721560,"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","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":[],"created_at":"2024-12-31T22:18:14.784Z","updated_at":"2026-03-22T22:30:16.764Z","avatar_url":"https://github.com/chaqchase.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rscrypt\n\nThe `Rscrypt` library provides functionality for creating and verifying password hashes.\n\n## Installation\n\nTo use the `rscrypt` library in your Rust project, add it as a dependency in your `Cargo.toml` file:\n\n```toml\n[dependencies]\nrscrypt = \"*\"\n```\n\nThen, run `cargo build` to download and compile the dependencies.\n\nAlternatively, you can use the following command for adding the latest version of the library:\n\n```shell\ncargo add rscrypt\n```\n\nOnce installed, you can import the library in your Rust code using:\n\n```rust\nuse rscrypt::{ Rscrypt };\n```\n\nThat's it! You're ready to use the `rscrypt` library in your Rust project.\n\n## Struct `Rscrypt`\n\nThis struct provides the following utility functions:\n\n### Function `compare(src: \u0026str, dst: \u0026str) -\u003e bool`\n\nThis function compares the plaintext password string `src` with the hashed password string `dst`. It returns `true` if they match, else `false`.\n\n```rust\nuse rscrypt::{Rscrypt};\n\nlet salt = Rscrypt::gen_salt(10);\nlet hashed = Rscrypt::hash(\u0026salt, \"password\");\nassert!(Rscrypt::compare(\"password\", \u0026hash));\n```\n\n### Function `gen_salt(cost: usize) -\u003e String`\n\nThis function generates a random salt value that can be used for hashing a password. The `cost` argument determines the number of computational rounds to perform during hashing.\n\n```rust\nuse rscrypt::{Rscrypt};\n\nlet salt = Rscrypt::gen_salt(10);\nlet hashed = Rscrypt::hash(\u0026salt, \"password\");\nassert!(Rscrypt::compare(\"password\", \u0026hashed));\n```\n\n### Function `get_salt(hash: \u0026str) -\u003e Option\u003cString\u003e`\n\nThis function extracts the salt value used for hashing from the given `hash` string.\n\n```rust\nuse rscrypt::{Rscrypt};\n\nlet hash = \"iIBDWiEk0118e29VbozxVmoCscUzu6k05cKGFbtgogI=$rscrypt$0.2.0$10$rLBARHBrWKCsvACVvBAN7O\";\nlet salt = Rscrypt::get_salt(\u0026hash);\nassert_eq!(salt, \"$rscrypt$0.2.0$10$rLBARHBrWKCsvACVvBAN7O\");\n```\n\n### Function `hash(salt: \u0026str, unhashed_str: \u0026str) -\u003e String`\n\nThis function hashes the plaintext password string `unhashed_str` with the given salt value `salt`.\n\n```rust\nuse rscrypt::{Rscrypt};\n\nlet hashed = Rscrypt::hash(\"$rscrypt$0.2.0$10$rLBARHBrWKCsvACVvBAN7O\", \"password\");\nassert_eq!(\n    hashed,\n    \"iIBDWiEk0118e29VbozxVmoCscUzu6k05cKGFbtgogI=$rscrypt$0.2.0$10$rLBARHBrWKCsvACVvBAN7O\"\n);\n```\n\n### Function `is_valid_hash(hash: \u0026str) -\u003e bool`\n\nThis function returns `true` if the given hash string is a valid hashed password string, else `false`.\n\n```rust\nuse rscrypt::{Rscrypt};\n\nlet hash = \"iIBDWiEk0118e29VbozxVmoCscUzu6k05cKGFbtgogI=$rscrypt$0.2.0$10$rLBARHBrWKCsvACVvBAN7O\";\nassert!(Rscrypt::is_valid_hash(\u0026hash));\n```\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Frscrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaqchase%2Frscrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Frscrypt/lists"}