-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypt.html
More file actions
186 lines (174 loc) · 5.25 KB
/
crypt.html
File metadata and controls
186 lines (174 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Crypt Class - Fuel Documentation</title>
<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../assets/js/nav.js"></script>
<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
<script type="text/javascript">
$(function() {
show_nav('classes', '../');
});
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
</script>
</head>
<body>
<header>
<h1>Fuel Documentation</h1>
</header>
<div id="main-nav"></div>
<section id="content">
<h2>Crypt Class</h2>
<p>
The Crypt class allows encrypt or decrypt a string. The Crypt class is also used internally by for example the Fuel Sessions class.
</p>
<p>It uses the encryption and hashing methods provided by PHPSecLib, so it's not dependent on external modules being available, such as mcrypt.</p>
<section>
<h2>Configuration</h2>
<p>
The Crypt class is configured through the <kbd>app/config/crypt.php</kbd> configuration file. It will be generated and populated with random values when you first use the Crypt class or if one of the required configuration values is missing.
</p>
<p class="note">
Note that this will require write access to app/config/crypt.php! If this is not possible, make sure all configuration settings are set!
</p>
<p>The following configuration settings can be defined:</p>
<table class="config">
<tbody>
<tr class="header">
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th>crypto_key</th>
<td>string</td>
<td>n/a</td>
<td>
Random encryption key value used in the encryption routines. Make sure you set this to something unique and random!
</td>
</tr>
<tr>
<th>crypto_iv</th>
<td>string</td>
<td>n/a</td>
<td>
Random encryption initialisation vector used in the encryption routines. Make sure you set this to something unique and random!
</td>
</tr>
<tr>
<th>crypto_hmac</th>
<td>string</td>
<td>n/a</td>
<td>
Random value used in the Hash-based Message Authentication Code (HMAC) routines. Make sure you set this to something unique and random!
</td>
</tr>
</tbody>
</table>
<p class="note">
If you assign keys manually, note that they are base64_encoded, and the length must be a multiple of 4 to be able to decode it. Make sure the length is correct!
</p>
</section>
<article>
<h4 id="method_encode">encode($value, $key = false)</h4>
<p>The <strong>encode</strong> method encrypts a string value, optionally with a custom encryption key.</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>No</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$value</kbd></th>
<td><i>Required</i></td>
<td>String value to encode.</td>
</tr>
<tr>
<th><kbd>$key</kbd></th>
<td><pre class="php"><code>false</code></pre></td>
<td>Optional custom key value to be used to encode the value passsed. If false, the config value '<strong>crypto_key</strong>' is used.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>string</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// encode a variable with a custom key
$value = Crypt::encode($value, 'R@nd0mK~Y');</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 id="method_decode">decode($value, $key = false)</h4>
<p>The <strong>decode</strong> method decrypts a string value, optionally with a custom key.</p>
<table class="method">
<tbody>
<tr>
<th class="legend">Static</th>
<td>No</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th class="description">Description</th>
</tr>
<tr>
<th><kbd>$value</kbd></th>
<td><i>Required</i></td>
<td>String value to decode.</td>
</tr>
<tr>
<th><kbd>$key</kbd></th>
<td><pre class="php"><code>false</code></pre></td>
<td>Optional custom key value to be used to decode the value passsed. If false, the config value '<strong>crypto_key</strong>' is used.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>mixed - String value with the decoded value, or <kbd>false</kbd> if the value could not be decoded.</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// decode a variable with a custom key
$value = Crypt::decode($value, 'R@nd0mK~Y');</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
</section>
<section id="footer">
<p>
<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
© 2010 - 2011 Fuel Development Team
</p>
</section>
</body>
</html>