This repository has been archived by the owner on Nov 14, 2019. It is now read-only.
-
-
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.
Line delimiters to Unix
- Loading branch information
crazy-max
committed
Dec 14, 2013
1 parent
83535f8
commit b18e4b5
Showing
2 changed files
with
112 additions
and
168 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 |
---|---|---|
|
@@ -36,66 +36,7 @@ There is also a method to encrypt/decrypt data using a symectric encryption stri | |
|
||
## Getting started | ||
|
||
```php | ||
<?php | ||
|
||
// Download CwsDump at https://github.com/crazy-max/CwsDump | ||
require_once '../CwsDump/class.cws.dump.php'; | ||
|
||
// Download CwsDebug at https://github.com/crazy-max/CwsDebug | ||
require_once '../CwsDebug/class.cws.debug.php'; | ||
|
||
require_once 'class.cws.crypto.php'; | ||
|
||
$cwsCrypto = new CwsCrypto(); | ||
$cwsCrypto->setDebugVerbose(CWSDEBUG_VERBOSE_DEBUG); // CWSDEBUG_VERBOSE_QUIET, CWSDEBUG_VERBOSE_SIMPLE, CWSDEBUG_VERBOSE_REPORT or CWSDEBUG_VERBOSE_DEBUG | ||
$cwsCrypto->setDebugMode(CWSDEBUG_MODE_ECHO); // CWSDEBUG_MODE_ECHO or CWSDEBUG_MODE_FILE | ||
|
||
/** | ||
* Create and check password hash | ||
*/ | ||
|
||
$password = '1337StrongPassword'; | ||
|
||
// You can use the second parameter or set the default mode. | ||
//$cwsCrypto->setDefaultMode(CWSCRYPTO_MODE_BCRYPT); | ||
|
||
// BCRYPT hash mode | ||
$hash = $cwsCrypto->hashPassword($password, CWSCRYPTO_MODE_BCRYPT); | ||
//$hash = $cwsCrypto->hashPassword($password); // To use if default mode setted | ||
$check = $cwsCrypto->checkPassword($password, $hash, CWSCRYPTO_MODE_BCRYPT); | ||
//$check = $cwsCrypto->checkPassword($password, $hash); // To use if default mode setted | ||
|
||
// PBKDF2 hash mode | ||
$hash = $cwsCrypto->hashPassword($password, CWSCRYPTO_MODE_PBKDF2); | ||
$check = $cwsCrypto->checkPassword($password, $hash, CWSCRYPTO_MODE_PBKDF2); | ||
|
||
/** | ||
* Encrypt/Decrypt datas | ||
*/ | ||
|
||
// Datas | ||
$datas = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor '; | ||
$datas .= 'incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation '; | ||
$datas .= 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit '; | ||
$datas .= 'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat '; | ||
$datas .= 'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. '; | ||
|
||
// Random encryption key of 56 chars | ||
// You can use the second parameter or set the default key. | ||
$datasEncryptionKey = 'En;4QfZ2kh>8_47rz;[email protected]+)[.v:W1Xi}N|Jo{Hx^u?'; | ||
//$cwsCrypto->setDefaultKey('En;4QfZ2kh>8_47rz;[email protected]+)[.v:W1Xi}N|Jo{Hx^u?'); | ||
|
||
// Encrypt | ||
$encryptedDatas = $cwsCrypto->encrypt($datas, $datasEncryptionKey); | ||
//$encryptedDatas = $cwsCrypto->encrypt($datas); // To use if default key setted | ||
|
||
// Decrypt | ||
$cwsCrypto->decrypt($encryptedDatas, $datasEncryptionKey); | ||
//$cwsCrypto->decrypt($datas); // To use if default key setted | ||
|
||
?> | ||
``` | ||
See ``index.php``. | ||
|
||
## Example | ||
|
||
|
Oops, something went wrong.