Skip to content
This repository has been archived by the owner on Nov 14, 2019. It is now read-only.

Commit

Permalink
Verbose bug
Browse files Browse the repository at this point in the history
Line delimiters to Unix
  • Loading branch information
crazy-max committed Dec 14, 2013
1 parent 83535f8 commit b18e4b5
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 168 deletions.
61 changes: 1 addition & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit b18e4b5

Please sign in to comment.