Skip to content

Commit 162e50d

Browse files
committed
Initial commit
1 parent 5fc8d40 commit 162e50d

File tree

14 files changed

+2092
-0
lines changed

14 files changed

+2092
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.iml
2+
.idea/
3+
build/
4+
vendor/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Davide Caruso
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<p align="center">
2+
<img src="https://github.com/davidecaruso/crypt/raw/master/logo.png" alt="Crypt" title="Crypt" />
3+
</p>
4+
5+
> **PHP** library to securely **encrypt/decrypt** strings.
6+
7+
Encrypt a string generating every time a random one which ever can be decrypted returning the original using a secret string.
8+
9+
## Install
10+
```shell script
11+
composer required davidecaruso/crypt
12+
```
13+
14+
## Simple usage
15+
```php
16+
<?php
17+
$salt = new \Crypt\Salt('don\'t tell anyone');
18+
$crypt = new \Crypt\Crypt($salt);
19+
20+
$encrypted = $crypt->encrypt('hey! don\'t let me be clear');
21+
$decrypted = $crypt->decrypt($encrypted);
22+
23+
echo "{$encrypted}\n";
24+
echo "{$decrypted}\n";
25+
```
26+
Output:
27+
```text
28+
c41da6c42e58ff58bfe7a2bf7271f89ace07f07b9c9ee71ced9efbd5d6539f966dab2f167bb22c463b37
29+
hey! don't let me be clear
30+
```
31+
32+
## Generate a random secret string
33+
### CLI
34+
Create a very very secret string through this command:
35+
```shell script
36+
composer run-script secret
37+
```
38+
Output:
39+
```text
40+
266eeed875cf3b015a2c62d2c52f1ffe3febe2c8082f9804597ab68b1a10c40d
41+
```
42+
43+
### Programmatically
44+
```php
45+
<?php
46+
$salt = new \Crypt\Salt();
47+
echo $salt->secret();
48+
```
49+
Output:
50+
```text
51+
d84a5a3882dce7377185be55446a1ef73b128c63a014b754e46b702984f9a287
52+
```

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "davidecaruso/crypt",
3+
"description": "PHP library to securely encrypt/decrypt strings.",
4+
"keywords": ["encrypt", "decrypt", "php", "hash"],
5+
"homepage": "https://github.com/davidecaruso/crypt",
6+
"type": "library",
7+
"require": {
8+
"php": "^7.3"
9+
},
10+
"require-dev": {
11+
"phpunit/phpunit": "^9.1"
12+
},
13+
"license": "MIT",
14+
"authors": [
15+
{
16+
"name": "Davide Caruso",
17+
"email": "[email protected]",
18+
"homepage": "https://about.me/davidecaruso"
19+
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Crypt\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Crypt\\Test\\": "tests/"
29+
}
30+
},
31+
"scripts": {
32+
"secret": "php scripts/secret.php",
33+
"phpcs": "phpcs src tests --standard=psr2 -sp --colors",
34+
"phpunit": "phpunit --verbose --colors=always",
35+
"coverage": "phpunit --verbose --colors=always --coverage-html build/coverage",
36+
"test": [
37+
"@phpcs",
38+
"@phpunit"
39+
]
40+
},
41+
"minimum-stability": "stable"
42+
}

0 commit comments

Comments
 (0)