{"id":20254816,"url":"https://github.com/chippyash/crypt","last_synced_at":"2026-05-09T08:44:21.691Z","repository":{"id":62501913,"uuid":"45298669","full_name":"chippyash/Crypt","owner":"chippyash","description":"Simple encryption for web systems","archived":false,"fork":false,"pushed_at":"2016-06-08T20:10:43.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T03:34:17.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chippyash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-31T11:10:15.000Z","updated_at":"2016-03-03T20:23:18.000Z","dependencies_parsed_at":"2022-11-02T12:16:02.355Z","dependency_job_id":null,"html_url":"https://github.com/chippyash/Crypt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FCrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FCrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FCrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chippyash%2FCrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chippyash","download_url":"https://codeload.github.com/chippyash/Crypt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241705908,"owners_count":20006398,"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-11-14T10:35:01.613Z","updated_at":"2026-05-09T08:44:21.622Z","avatar_url":"https://github.com/chippyash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chippyash/Crypt\n\n## Quality Assurance\n\n![PHP 5.3](https://img.shields.io/badge/PHP-5.3-blue.svg)\n![PHP 5.4](https://img.shields.io/badge/PHP-5.4-blue.svg)\n![PHP 5.5](https://img.shields.io/badge/PHP-5.5-blue.svg)\n![PHP 5.6](https://img.shields.io/badge/PHP-5.6-blue.svg)\n![PHP 7](https://img.shields.io/badge/PHP-7-blue.svg)\n[![Build Status](https://travis-ci.org/chippyash/Crypt.svg?branch=master)](https://travis-ci.org/chippyash/Crypt)\n[![Test Coverage](https://codeclimate.com/github/chippyash/Crypt/badges/coverage.svg)](https://codeclimate.com/github/chippyash/Crypt/coverage)\n[![Code Climate](https://codeclimate.com/github/chippyash/Crypt/badges/gpa.svg)](https://codeclimate.com/github/chippyash/Crypt)\n\nThe above badges represent the current development branch.  As a rule, I don't push\n to GitHub unless tests, coverage and usability are acceptable.  This may not be\n true for short periods of time; on holiday, need code for some other downstream\n project etc.  If you need stable code, use a tagged version. Read 'Further Documentation'\n and 'Installation'.\n \n The Travis tests cover multiple versions of PHP. However, they do not allow usage of system\n   commands, hence the getMac() method of Crypt.php doesn't work on the Travis servers.\n   Check it out for yourself.\n \n## What?\n\nProvides a simple encryption capability\n\n## Why?\n\nEncryption is not generally straightforward.  This library tries to ease the pain.\nAt the present time, a single verified encryption method is provided.\n\nAs the majority of web encryption requires that you are able to store the value in\ncookies, database tables etc, by default the encrypted value is encoded using Base 64.\nYou can switch that off if required.\n\n## How\n\nThe encryption methods supported by this library all require an encryption key.  You can\ngenerate this (on a \\*nix based system at least,) by running `uuidgen`\n\nYou need to supply an encryption method to the Crypt class.  At present one is provided\nfor you, Rijndael256, but you can implement others by implementing the MethodInterface.\n\nThe supplied Rijndael256 method is capable of encrypting any PHP serializable object.\n\n\u003cpre\u003e\nuse Chippyash\\Crypt\\Crypt;\nuse Chippyash\\Crypt\\Crypt\\Method\\Rijndael256;\nuse chippyash\\Type\\String\\StringType;\nuse chippyash\\Type\\BoolType;\n\n$crypt = new Crypt(new StringType('my seed value'), new Rijndael256());\n \n$encrypted = $crypt-\u003eencrypt($someValue);\n$decrypted = $crypt-\u003edecrypt($encrypted);\n\u003c/pre\u003e\n\nBy default the encrypted value is encoded using Base64.  You can get the raw value thus:\n\n\u003cpre\u003e\n$encrypted = $crypt-\u003eencrypt($someValue, new BoolType(false));\n\u003c/pre\u003e\n\nIf you are not using Base64 encoding to encrypt, you need to switch it off in the decrypt as well:\n\n\u003cpre\u003e\n$decrypted = $crypt-\u003edecrypt($encrypted, new BoolType(false));\n\u003c/pre\u003e\n\nBy default, on \\*nix based machines, the seed that you supply on construction is mixed\nwith the mac address of the machine that the code is running on, if it can be found.  This ensures that only\nthat machine can encrypt and decrypt a given value.  If you do not want this, say for instance\nthat you are running on load balanced machines and storing in a central database, you can\nswitch it off:\n\n\u003cpre\u003e\n$crypt = new Crypt(new StringType('my seed value'), new Rijndael256());\n$crypt-\u003esetUseMacAddress(new BoolType(false));\n\u003c/pre\u003e\n \n### Development only\n\n__This library is no longer maintained and serves only as an example of encryption and\nas a holder for the work of others before me__ \n\nIf you have a wish to pick this up and take it further, please contact me.\n\nonly on master branch at present\n\nAs an example of how you can wrap other libraries into this, I've supplied the Blowfish\nmethod, which requires the Zend Crypt library.  \n\n\u003cpre\u003e\nuse Chippyash\\Crypt\\Crypt\\Method\\Blowfish;\n\n$crypt = new Crypt(new StringType('my seed value'), new Blowfish());\n\u003c/pre\u003e\n\nIf you want to do very serious cryptography\nthe Zend Crypt library is a good starting point.  If you just want sound and simple, use\nthis library.  You will need to  use the now default `composer install` to bring in dev \ndependencies to use the Zend stuff. If you like it then add `\"zendframework/zend-crypt\": \"~2.5.0\"`\nto your project composer 'requires' statement;\n\n## Further documentation\n\n[Test Contract](https://github.com/chippyash/Crypt/blob/master/docs/Test-Contract.md) in the docs directory.\nFor Symfony users, you'll also find an example DIC definition in the docs directory\n\nCheck out [ZF4 Packages](http://zf4.biz/packages?utm_source=github\u0026utm_medium=web\u0026utm_campaign=blinks\u0026utm_content=crypt) for more packages\n\n### UML\n\n![class diagram](https://github.com/chippyash/Crypt/blob/master/docs/crypt-classes.png)\n\n## Changing the library\n\n1.  fork it\n2.  write the test\n3.  amend it\n4.  do a pull request\n\nFound a bug you can't figure out?\n\n1.  fork it\n2.  write the test\n3.  do a pull request\n\nNB. Make sure you rebase to HEAD before your pull request\n\nOr - raise an issue ticket.\n\n## Where?\n\nThe library is hosted at [Github](https://github.com/chippyash/Crypt). It is\navailable at [Packagist.org](https://packagist.org/packages/chippyash/crypt)\n\n### Installation\n\nInstall [Composer](https://getcomposer.org/)\n\n#### For production\n\n\u003cpre\u003e\n    \"chippyash/crypt\": \"~1.0.0\"\n\u003c/pre\u003e\n\nOr to use the latest, possibly unstable version:\n\n\u003cpre\u003e\n    \"chippyash/crypt\": \"dev-master\"\n\u003c/pre\u003e\n\nTo use the Zend cryptography lib under my lib add the `\"zendframework/zend-crypt\": \"~2.5.0\"`\nline to your composer require section.\n\n#### For development\n\nClone this repo, and then run Composer in local repo root to pull in dependencies\n\n\u003cpre\u003e\n    git clone git@github.com:chippyash/Crypt.git Crypt\n    cd Crypt\n    composer install\n\u003c/pre\u003e\n\nTo run the tests:\n\n\u003cpre\u003e\n    cd Crypt\n    vendor/bin/phpunit -c test/phpunit.xml test/\n\u003c/pre\u003e\n\n\n## License\n\nThis software library is released under the [GNU GPL V3 or later license](http://www.gnu.org/copyleft/gpl.html)\n\nThis software library is Copyright (c) 2015, Ashley Kitson, UK\n\nThis software library contains code items that are derived from other works: \n\nNone of the contained code items breaks the overriding license, or vice versa,  as far as I can tell. \nSo as long as you stick to GPL V3+ then you are safe. If at all unsure, please seek appropriate advice.\n\nIf the original copyright owners of the derived code items object to this inclusion, please contact the author.\n\nA commercial license is available for this software library, please contact the author. \nIt is normally free to deserving causes, but gets you around the limitation of the GPL\nlicense, which does not allow unrestricted inclusion of this code in commercial works.\n\n## Thanks\n\nI didn't do this by myself. I'm deeply indebted to those that trod the path before me.\n \nThe Rijndael256 cryptography method is based on code created by Andrew Johnson. I can find\nno current location or link for Andrew, so if you know him (he created Cryptastic,) please\ndo let me know.\n\n## History\n\nV1.0.0 Initial Release\n\nV1.1.0 Update dependencies\n\nV1.1.1 Add link to packages\n\nAbandoned.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fcrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchippyash%2Fcrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchippyash%2Fcrypt/lists"}