{"id":17143246,"url":"https://github.com/debianmaster/aes-encryption-rust-example","last_synced_at":"2025-09-10T14:37:26.846Z","repository":{"id":224803138,"uuid":"764268447","full_name":"debianmaster/aes-encryption-rust-example","owner":"debianmaster","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-28T16:21:40.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T14:53:46.790Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/debianmaster.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-27T19:24:50.000Z","updated_at":"2024-02-28T08:10:54.000Z","dependencies_parsed_at":"2024-12-01T18:44:41.781Z","dependency_job_id":null,"html_url":"https://github.com/debianmaster/aes-encryption-rust-example","commit_stats":null,"previous_names":["debianmaster/aes-encryption-rust-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Faes-encryption-rust-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Faes-encryption-rust-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Faes-encryption-rust-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Faes-encryption-rust-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debianmaster","download_url":"https://codeload.github.com/debianmaster/aes-encryption-rust-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245241648,"owners_count":20583286,"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-10-14T20:34:03.502Z","updated_at":"2025-03-24T09:25:25.399Z","avatar_url":"https://github.com/debianmaster.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"```sh\ngit clone https://github.com/debianmaster/aes-encryption-rust-example.git\ncd aes-encryption-rust-example.git\ncargo run \n```\n\n```sh\ncurl -X POST http://127.0.0.1:8080/encrypt \\\n-H \"Content-Type: application/json\" \\\n-d '{\"data\":\"Hello, AES-256-CBC!\",\"key\":\"4050ba0bc19dc38e2587a0837db956164f754c2364519aff1f07198612d3bf3a\",\"iv\":\"5fb160e67acd8772939ba5aee58fba2a\"}'\n\n{\"encrypted_data\":\"118e7ab1869c9d3d94199202ffc78c2760813a2c9f7b1f0024c5073c9a6a9ac3\",\"key\":\"4050ba0bc19dc38e2587a0837db956164f754c2364519aff1f07198612d3bf3a\",\"iv\":\"5fb160e67acd8772939ba5aee58fba2a\"}\n```\n\n\n```sh\ncurl -X POST http://127.0.0.1:8080/decrypt \\\n-H \"Content-Type: application/json\" \\\n-d '{\"encrypted_data\":\"118e7ab1869c9d3d94199202ffc78c2760813a2c9f7b1f0024c5073c9a6a9ac3\",\"key\":\"4050ba0bc19dc38e2587a0837db956164f754c2364519aff1f07198612d3bf3a\",\"iv\":\"5fb160e67acd8772939ba5aee58fba2a\"}'\n```\n\n\n\n\n```rust\nuse aes::Aes256;\nuse block_modes::{BlockMode, Cbc};\nuse block_modes::block_padding::Pkcs7;\nuse rand::{thread_rng, Rng};\nuse hex::encode; // Removed decode to resolve the warning\n\ntype Aes256Cbc = Cbc\u003cAes256, Pkcs7\u003e;\n\nfn main() {\n    let key = thread_rng().gen::\u003c[u8; 32]\u003e(); // Generate a random 256-bit key\n    let iv = thread_rng().gen::\u003c[u8; 16]\u003e(); // Generate a random initialization vector (IV)\n    let data = b\"Hello, AES-256-CBC!\"; // Data to be encrypted\n\n    // Create the cipher for encryption\n    let cipher = Aes256Cbc::new_from_slices(\u0026key, \u0026iv).unwrap();\n\n    // Encrypt the data\n    let encrypted_data = cipher.encrypt_vec(data);\n    println!(\"Encrypted data: {}\", encode(\u0026encrypted_data));\n\n    // Create the cipher again for decryption\n    let cipher = Aes256Cbc::new_from_slices(\u0026key, \u0026iv).unwrap();\n\n    // Decrypt the data\n    let decrypted_data = cipher.decrypt_vec(\u0026encrypted_data).unwrap();\n    println!(\"Decrypted data: {}\", String::from_utf8_lossy(\u0026decrypted_data));\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebianmaster%2Faes-encryption-rust-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebianmaster%2Faes-encryption-rust-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebianmaster%2Faes-encryption-rust-example/lists"}