-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
733 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# IDE | ||
/.idea | ||
|
||
# Composer | ||
/vendor | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: php | ||
php: | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
|
||
env: | ||
- PHP_BIN=php | ||
- PHP_BIN=php-cgi | ||
|
||
before_install: | ||
- phpenv config-rm xdebug.ini || return 0 # Turn off XDebug | ||
|
||
install: | ||
- travis_retry composer install # Composer | ||
|
||
script: | ||
- vendor/bin/tester -p $PHP_BIN tests -s # Tests | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# crypt | ||
Small library for encryption via [phpseclib](https://github.com/phpseclib/phpseclib) | ||
|
||
[![Build Status](https://travis-ci.org/SiViN/crypt.svg?branch=master)](https://travis-ci.org/SiViN/crypt) | ||
[![License](https://poser.pugx.org/sivin/crypt/license)](https://packagist.org/packages/sivin/crypt) | ||
[![Total Downloads](https://poser.pugx.org/sivin/crypt/downloads)](https://packagist.org/packages/sivin/crypt) | ||
|
||
1. Install via composer | ||
```yaml | ||
composer require sivin/crypt | ||
``` | ||
|
||
2. Register extension in `config.neon`: | ||
```php | ||
extensions: | ||
crypt: SiViN\Crypt\DI\CryptExtension | ||
``` | ||
|
||
3. Create or use your key/s: | ||
```php | ||
/** @var Crypt */ | ||
private $crypt; | ||
|
||
public function __construct(Crypt $crypt) | ||
{ | ||
$this->crypt = $crypt; | ||
} | ||
... | ||
$keys = $this->crypt->createKeyPair() | ||
$privateKeyRaw = $keys['privateKeyRaw']; | ||
$publicKeyRaw = $keys['publicKeyRaw']; | ||
``` | ||
|
||
4. Use your own key or define it in a `config.local.neon`: | ||
```php | ||
$crypt->setPublicKey($myPublicKeyForEncrypt); | ||
$crypt->setPrivateKey($myPrivateKeyForDecrypt); | ||
//if there is a private key with a password | ||
$crypt->setPrivateKeyPassword($myPivateKeyPasswordForDecrypt); | ||
``` | ||
|
||
or in a `config.local.neon`: | ||
|
||
```php | ||
crypt: | ||
publicKeyPath: publicKeyFile.pub #for encrypting | ||
privateKeyPath: privateKeyFile.key #for decrypting | ||
privateKeyPassword: 'PrivateKeyPassword' #optional | ||
``` | ||
>If you only want to encrypt/decrypt, just define the encrypting/decrypting key | ||
|
||
5. And finally?: | ||
```php | ||
$encryptedStr = $crypt->encryptRijndaelMessage($stringToEncode); //for transport | ||
$decryptedStr = $crypt->decryptRijndaelMessage($encryptedStr); | ||
|
||
$encryptedStr = $crypt->encryptRsa($stringToEncode); | ||
$decryptedStr = $crypt->decryptRsa($encryptedStr); | ||
|
||
$encryptedStr = $crypt->encryptRijndael($stringToEncode); | ||
$decryptedStr = $crypt->decryptRijndael($encryptedStr); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "sivin/crypt", | ||
"type": "library", | ||
"description": "Small library for encryption via phpseclib", | ||
"keywords": [ | ||
"security", | ||
"crypt", | ||
"nette", | ||
"rsa", | ||
"aes", | ||
"blowfish", | ||
"twofish", | ||
"ssh", | ||
"sftp", | ||
"x509", | ||
"x.509", | ||
"asn1", | ||
"asn.1", | ||
"BigInteger" | ||
], | ||
"require": { | ||
"php": ">= 7.1", | ||
"ext-openssl": "*", | ||
"phpseclib/phpseclib": "^2.0", | ||
"nette/di": "^2.4", | ||
"tracy/tracy": "^2.6" | ||
}, | ||
"require-dev": { | ||
"ninjify/nunjuck": "^0.3.0@dev" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Milan Sivak", | ||
"email": "sivin@atlas.cz" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"SiViN\\Crypt\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"SiViN\\Crypt\\Tests\\": "tests" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
Oops, something went wrong.