{"id":21874556,"url":"https://github.com/smoren/encryption-tools-php","last_synced_at":"2025-04-15T01:24:15.519Z","repository":{"id":57054033,"uuid":"394769066","full_name":"Smoren/encryption-tools-php","owner":"Smoren","description":"Tools for encryption/decryption and signing/verifying (wraps openssl lib). Symmetric and asymmetric (RSA-based) encryption.","archived":false,"fork":false,"pushed_at":"2023-10-25T09:05:58.000Z","size":47,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-25T15:20:48.629Z","etag":null,"topics":["cryptography","encryption","rsa"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/Smoren.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-10T20:06:25.000Z","updated_at":"2024-03-18T08:38:39.000Z","dependencies_parsed_at":"2024-11-28T08:31:15.538Z","dependency_job_id":null,"html_url":"https://github.com/Smoren/encryption-tools-php","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"3124aa895d26a770500f7757a703da034d64d784"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fencryption-tools-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fencryption-tools-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fencryption-tools-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fencryption-tools-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smoren","download_url":"https://codeload.github.com/Smoren/encryption-tools-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986924,"owners_count":21194143,"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":["cryptography","encryption","rsa"],"created_at":"2024-11-28T07:12:41.406Z","updated_at":"2025-04-15T01:24:15.500Z","avatar_url":"https://github.com/Smoren.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# encryption-tools\n\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/smoren/encryption-tools)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Smoren/encryption-tools-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Smoren/encryption-tools-php/?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/Smoren/encryption-tools-php/badge.svg?branch=master)](https://coveralls.io/github/Smoren/encryption-tools-php?branch=master)\n![Build and test](https://github.com/Smoren/encryption-tools-php/actions/workflows/test_master.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nTools for encryption/decryption and signing/verifying (wraps openssl lib).\n\n* Symmetric\n* Asymmetric (RSA-based)\n\n### Install to your project\n```shell script\ncomposer require smoren/encryption-tools\n``` \n\n### Unit testing\n```shell script\ncomposer install\ncomposer test-init\ncomposer test\n```\n\n### Usage\n\n#### Symmetric encryption/decryption\n```php\nuse Smoren\\EncryptionTools\\Helpers\\SymmetricEncryptionHelper;\n\n$data = [\"some\", \"data\" =\u003e \"to\", \"encrypt\"];\n$secretKey = uniqid();\n\n$dataEncrypted = SymmetricEncryptionHelper::encrypt($data, $secretKey);\n$dataDecrypted = SymmetricEncryptionHelper::decrypt($dataEncrypted, $secretKey);\nprint_r($dataDecrypted);\n\n$dataEncrypted = SymmetricEncryptionHelper::encrypt($data, $secretKey, 'camellia-256-ofb');\n$dataDecrypted = SymmetricEncryptionHelper::decrypt($dataEncrypted, $secretKey, 'camellia-256-ofb');\nprint_r($dataDecrypted);\n```\n\n#### Asymmetric encryption/decryption (RSA-based)\n```php\nuse Smoren\\EncryptionTools\\Helpers\\AsymmetricEncryptionHelper;\n\n$data = [\"some\", \"data\" =\u003e \"to\", \"encrypt\"];\n[$privateKey, $publicKey] = AsymmetricEncryptionHelper::generateKeyPair();\n\n$dataEncrypted = AsymmetricEncryptionHelper::encryptByPrivateKey($data, $privateKey);\n$dataDecrypted = AsymmetricEncryptionHelper::decryptByPublicKey($dataEncrypted, $publicKey);\nprint_r($dataDecrypted);\n\n$dataEncrypted = AsymmetricEncryptionHelper::encryptByPublicKey($data, $publicKey);\n$dataDecrypted = AsymmetricEncryptionHelper::decryptByPrivateKey($dataEncrypted, $privateKey);\nprint_r($dataDecrypted);\n```\n\n#### Asymmetric signing/verifying (RSA-based)\n```php\nuse Smoren\\EncryptionTools\\Helpers\\AsymmetricEncryptionHelper;\nuse Smoren\\EncryptionTools\\Exceptions\\AsymmetricEncryptionException;\n\n$data = [\"some\", \"data\" =\u003e \"to\", \"encrypt\"];\n[$privateKey, $publicKey] = AsymmetricEncryptionHelper::generateKeyPair();\n\n$signature = AsymmetricEncryptionHelper::sign($data, $privateKey);\n\ntry {\n    AsymmetricEncryptionHelper::verify($data, $signature, $publicKey);\n} catch(AsymmetricEncryptionException $e) {\n    // ... handling exception if cannot verify signature\n}\n```\n\n#### Asymmetric encryption/decryption (RSA-based) for large data\n```php\nuse Smoren\\EncryptionTools\\Helpers\\AsymmetricLargeDataEncryptionHelper;\n\n$data = file_get_contents('file_with_large_data.txt');\n[$privateKey, $publicKey] = AsymmetricLargeDataEncryptionHelper::generateKeyPair();\n\n$dataEncrypted = AsymmetricLargeDataEncryptionHelper::encryptByPrivateKey($data, $privateKey);\n$dataDecrypted = AsymmetricLargeDataEncryptionHelper::decryptByPublicKey($dataEncrypted, $publicKey);\nprint_r($dataDecrypted);\n\n$dataEncrypted = AsymmetricLargeDataEncryptionHelper::encryptByPublicKey($data, $publicKey);\n$dataDecrypted = AsymmetricLargeDataEncryptionHelper::decryptByPrivateKey($dataEncrypted, $privateKey);\nprint_r($dataDecrypted);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fencryption-tools-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoren%2Fencryption-tools-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fencryption-tools-php/lists"}