Skip to content

Commit 9a5b544

Browse files
committed
Fixed grammar and formatting issues. Added in a section about installing
Microsoft CAPICOM on Windows.
1 parent f4b4c68 commit 9a5b544

2 files changed

Lines changed: 90 additions & 40 deletions

File tree

README

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,76 @@
1-
phpCrypt 0.3.2
1+
phpCrypt 0.4
22
Ryan Gilfether
33
http://www.gilfether.com/phpcrypt
44

55

66
About
77
=============
8-
phpCrypt is an Open Source PHP Encryption library that does not require
9-
or use the mCrypt or any other PHP extension. It's not as fast
10-
as PHP's mCrypt extention, however if you are in a situation where you
11-
can not use the mCrypt library, phpCrypt is a suitable alternative.
8+
phpCrypt is an encryption library written in PHP from scratch. It aims to
9+
implement all major encryption ciphers, modes, and other tools used for
10+
encryption and decryption. phpCrypt does not rely on mCrypt, other PHP
11+
extenions, or PEAR libraries.
1212

13-
This version of phpCrypt requires PHP 5.3 or later.
13+
It currently support many popular encryption ciphers. In addition it
14+
supports many popular modes of encryption. There are also tools to implement
15+
the different padding schemes, as well as multiple methods of creating an
16+
Initialization Vecotor (IV) for modes that require one.
1417

15-
Please visit phpCrypt's website for a list of options and constants
16-
used in phpCrypt. phpCrypt's website also lists the required key
17-
sizes for Ciphers, as well as which Modes work with which Ciphers.
18-
http://www.gilfether.com/phpcrypt
19-
20-
All Cipher algorithms were implemented using freely available resources
21-
found online and in books.
18+
phpCrypt is developed by Ryan Gilfether <http://www.gilfether.com/phpcrypt>
2219

2320

2421
Documentation
2522
=============
26-
Visit the phpCrypt website at http://www.gilfether.com/phpcrypt. Also,
27-
the 'examples' directory has demo code of phpCrypt in use. Below is an
28-
example of encrypting a string.
23+
The phpCrypt website at http://www.gilfether.com/phpcrypt lists much of the
24+
information you need to begin. The phpCrypt website lists all the constants
25+
you need to select ciphers, modes, padding, and IV methods. In addition,
26+
phpCrypt comes with an `examples` directory which has sample code to help get
27+
you started.
28+
29+
Using phpCrypt is easy to use. An example of encrypting a string using AES-128
30+
with CTR mode is demonstrated below:
31+
32+
<?php
33+
include("/path/to/phpcrypt/phpCrypt.php");
34+
use PHP_Crypt\PHP_Crypt as PHP_Crypt;
35+
36+
$data = "This is my secret message.";
37+
$key = "MySecretKey01234";
38+
$crypt = new PHP_Crypt($key, PHP_Crypt::CIPHER_AES_128, PHP_Crypt::MODE_CTR);
39+
40+
$iv = $crypt->createIV();
41+
$encrypt = $crypt->encrypt($data);
42+
43+
$crypt->IV($iv);
44+
$decrypt = $crypt->decrypt($encrypt);
45+
?>
46+
47+
48+
Generating Random Numbers on Windows
49+
====================================
50+
51+
By default phpCrypt will use the PHP mt_rand() random number generator on
52+
Windows to create an IV. You have the option to use the random number generator
53+
found in the Microsoft CAPICOM SDK which is more secure.
54+
55+
Before this will work you must install the Microsoft CAPICOM SDK and enable the
56+
PHP com_dotnet extension:
57+
58+
* Download CAPICOM from Microsoft at
59+
http://www.microsoft.com/en-us/download/details.aspx?id=25281
60+
61+
* Double click the MSI file you downloaded, and follow the install directions
62+
63+
* Open a command prompt and register the DLL:
64+
regsvr32 C:\Program Files\PATH TO\CAPICOM SDK\Lib\X86\capicom.dll
2965

30-
<?php
31-
include("/path/to/phpcrypt/phpCrypt.php");
32-
use PHP_Crypt\PHP_Crypt as PHP_Crypt;
66+
* Now edit php.ini to enable the com_dotnet extension:
67+
extension=php_com_dotnet.dll
3368

34-
$data = "This is my secret message.";
35-
$key = "MySecretKey01234";
36-
$crypt = new PHP_Crypt($key, PHP_Crypt::CIPHER_AES_128, PHP_Crypt::MODE_CTR);
69+
* If you are running PHP as an Apache module, restart Apache.
3770

38-
$iv = $crypt->createIV();
39-
$encrypt = $crypt->encrypt($data);
71+
To use the Windows random number generator in CAPICOM you would call creatIV() like so:
4072

41-
$crypt->IV($iv);
42-
$decrypt = $crypt->decrypt($encrypt);
43-
?>
73+
$iv = $crypt->createIV(PHP_Crypt::IV_WIN_COM);
4474

4575

4676
GPL Stuff

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ phpCrypt - A PHP Encryption Library
44
WHAT IS PHPCRYPT?
55
-----------------
66

7-
phpCrypt is an encryption library written in PHP from scratch by
8-
Ryan Gilfether. It aims to implement all major encryption ciphers, modes,
9-
and other tools used for encryption and decryption. phpCrypt does not rely
10-
on mCrypt or any other PHP extenions or PEAR libraries.
7+
phpCrypt is an encryption library written in PHP from scratch. It aims to
8+
implement all major encryption ciphers, modes, and other tools used for
9+
encryption and decryption. phpCrypt does not rely on mCrypt, other PHP
10+
extenions, or PEAR libraries.
1111

1212
It currently support many popular encryption ciphers. In addition it
13-
supports many popular encryption modes. There are also tools to implement
14-
the different padding schemes, as well as methods of creating an
15-
Initialization Vecotor (IV) for modes that require an IV.
13+
supports many popular modes of encryption. There are also tools to implement
14+
the different padding schemes, as well as multiple methods of creating an
15+
Initialization Vecotor (IV) for modes that require one.
1616

1717
phpCrypt is developed by Ryan Gilfether <http://www.gilfether.com/phpcrypt>
1818

@@ -24,7 +24,7 @@ phpCrypt version 0.x works with PHP 5.3 or later. It will run on any
2424

2525
SUPPORTED ENCRYPTION CIPHERS & MODES
2626
------------------------------------
27-
The list of supported encryption ciphers and modes is constantly growing, each
27+
The list of supported encryption ciphers and modes is continually growing, each
2828
new version of phpCrypt will add new ciphers or modes. The current list of
2929
supported ciphers and modes are listed below:
3030

@@ -42,12 +42,12 @@ DOCUMENTATION
4242

4343
The phpCrypt website at http://www.gilfether.com/phpcrypt lists much of the
4444
information you need to begin. The phpCrypt website lists all the constants
45-
you need to select ciphers, modes, padding type, and IV creation methods.
46-
In addition, phpCrypt comes with an `examples` directory which has sample code
47-
to help get you started.
45+
you need to select ciphers, modes, padding, and IV methods. In addition,
46+
phpCrypt comes with an `examples` directory which has sample code to help get
47+
you started.
4848

49-
Using phpCrypt is not complicated. A simple example of encrypting a string
50-
using AES-128 with CTR mode is demonstrated below:
49+
Using phpCrypt is easy to use. An example of encrypting a string using AES-128
50+
with CTR mode is demonstrated below:
5151

5252
<?php
5353
include("/path/to/phpcrypt/phpCrypt.php");
@@ -64,6 +64,26 @@ using AES-128 with CTR mode is demonstrated below:
6464
$decrypt = $crypt->decrypt($encrypt);
6565
?>
6666

67+
GENERATING RANDOM NUMBERS ON WINDOWS
68+
------------------------------------
69+
70+
By default phpCrypt will use the PHP mt_rand() random number function on Windows
71+
to create an IV. You have the option to use the random number generator found in the
72+
Microsoft CAPICOM SDK which is more secure.
73+
74+
Before this will work you must install the Microsoft CAPICOM SDK and enable the PHP
75+
com_dotnet extension:
76+
77+
* Download CAPICOM from Microsoft at http://www.microsoft.com/en-us/download/details.aspx?id=25281
78+
* Double click the MSI file you downloaded and follow the install directions
79+
* Open a command prompt and register the DLL: `regsvr32 C:\Program Files\PATH TO\CAPICOM SDK\Lib\X86\capicom.dll`
80+
* Now edit php.ini to enable the com_dotnet extension: `extension=php_com_dotnet.dll`
81+
* If you are running PHP as an Apache module, restart Apache.
82+
83+
To use the Windows random number generator in CAPICOM you would call createIV() like so:
84+
85+
$iv = $crypt->createIV(PHP_Crypt::IV_WIN_COM);
86+
6787
GPL STUFF
6888
---------
6989

0 commit comments

Comments
 (0)