1 | <?php |
||
32 | class Base32{ |
||
33 | |||
34 | /** |
||
35 | * charset |
||
36 | * |
||
37 | * Internal holder of the current character set. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public static $charset = Base32Characters::RFC3548; |
||
42 | |||
43 | /** |
||
44 | * setCharset |
||
45 | * |
||
46 | * Used to set the internal _charset variable |
||
47 | * I've left it so that people can arbirtrarily set their |
||
48 | * own charset |
||
49 | * |
||
50 | * @param string $charset The character set you want to use |
||
51 | * |
||
52 | * @throws \chillerlan\Base32\Base32Exception |
||
53 | */ |
||
54 | public static function setCharset($charset = Base32Characters::RFC3548){ |
||
62 | |||
63 | /** |
||
64 | * str2bin |
||
65 | * |
||
66 | * Converts any ascii string to a binary string |
||
67 | * |
||
68 | * @param string $str The string you want to convert |
||
69 | * |
||
70 | * @return string String of 0's and 1's |
||
71 | */ |
||
72 | public static function str2bin($str){ |
||
77 | |||
78 | /** |
||
79 | * bin2str |
||
80 | * |
||
81 | * Converts a binary string to an ascii string |
||
82 | * |
||
83 | * @param string $str The string of 0's and 1's you want to convert |
||
84 | * |
||
85 | * @return string The ascii output |
||
86 | * @throws \chillerlan\Base32\Base32Exception |
||
87 | */ |
||
88 | public static function bin2str($str){ |
||
100 | |||
101 | /** |
||
102 | * fromBin |
||
103 | * |
||
104 | * Converts a correct binary string to base32 |
||
105 | * |
||
106 | * @param string $str The string of 0's and 1's you want to convert |
||
107 | * |
||
108 | * @return string String encoded as base32 |
||
109 | * @throws \chillerlan\Base32\Base32Exception |
||
110 | */ |
||
111 | public static function fromBin($str){ |
||
136 | |||
137 | /** |
||
138 | * toBin |
||
139 | * |
||
140 | * Accepts a base32 string and returns an ascii binary string |
||
141 | * |
||
142 | * @param string $str The base32 string to convert |
||
143 | * |
||
144 | * @return string Ascii binary string |
||
145 | * @throws \chillerlan\Base32\Base32Exception |
||
146 | */ |
||
147 | public static function toBin($str){ |
||
168 | |||
169 | /** |
||
170 | * fromString |
||
171 | * |
||
172 | * Convert any string to a base32 string |
||
173 | * This should be binary safe... |
||
174 | * |
||
175 | * @param string $str The string to convert |
||
176 | * |
||
177 | * @return string The converted base32 string |
||
178 | */ |
||
179 | public static function fromString($str){ |
||
182 | |||
183 | /** |
||
184 | * toString |
||
185 | * |
||
186 | * Convert any base32 string to a normal sctring |
||
187 | * This should be binary safe... |
||
188 | * |
||
189 | * @param string $str The base32 string to convert |
||
190 | * |
||
191 | * @return string The normal string |
||
192 | */ |
||
193 | public static function toString($str){ |
||
204 | |||
205 | /** |
||
206 | * @param string $str |
||
207 | * |
||
208 | * @throws \chillerlan\Base32\Base32Exception |
||
209 | */ |
||
210 | protected static function checkLength($str){ |
||
215 | |||
216 | /** |
||
217 | * @param string $str |
||
218 | * |
||
219 | * @throws \chillerlan\Base32\Base32Exception |
||
220 | */ |
||
221 | protected static function checkBin($str){ |
||
226 | |||
227 | /** |
||
228 | * @param string $str |
||
229 | * |
||
230 | * @throws \chillerlan\Base32\Base32Exception |
||
231 | */ |
||
232 | protected static function checkCharacterSet($str){ |
||
237 | |||
238 | } |
||
239 |