1 | <?php |
||
53 | class Base32{ |
||
54 | |||
55 | /** |
||
56 | * charset |
||
57 | * |
||
58 | * Internal holder of the current character set. |
||
59 | * |
||
60 | * @access protected |
||
61 | * @var string |
||
62 | */ |
||
63 | public static $charset = Base32Characters::RFC3548; |
||
64 | |||
65 | /** |
||
66 | * setCharset |
||
67 | * |
||
68 | * Used to set the internal _charset variable |
||
69 | * I've left it so that people can arbirtrarily set their |
||
70 | * own charset |
||
71 | * |
||
72 | * @param string $charset The character set you want to use |
||
73 | * |
||
74 | * @throws \chillerlan\Base32\Base32Exception |
||
75 | */ |
||
76 | public static function setCharset($charset = Base32Characters::RFC3548){ |
||
84 | |||
85 | /** |
||
86 | * str2bin |
||
87 | * |
||
88 | * Converts any ascii string to a binary string |
||
89 | * |
||
90 | * @param string $str The string you want to convert |
||
91 | * |
||
92 | * @return string String of 0's and 1's |
||
93 | */ |
||
94 | public static function str2bin($str){ |
||
99 | |||
100 | /** |
||
101 | * bin2str |
||
102 | * |
||
103 | * Converts a binary string to an ascii string |
||
104 | * |
||
105 | * @param string $str The string of 0's and 1's you want to convert |
||
106 | * |
||
107 | * @return string The ascii output |
||
108 | * @throws \chillerlan\Base32\Base32Exception |
||
109 | */ |
||
110 | public static function bin2str($str){ |
||
122 | |||
123 | /** |
||
124 | * fromBin |
||
125 | * |
||
126 | * Converts a correct binary string to base32 |
||
127 | * |
||
128 | * @param string $str The string of 0's and 1's you want to convert |
||
129 | * |
||
130 | * @return string String encoded as base32 |
||
131 | * @throws \chillerlan\Base32\Base32Exception |
||
132 | */ |
||
133 | public static function fromBin($str){ |
||
158 | |||
159 | /** |
||
160 | * toBin |
||
161 | * |
||
162 | * Accepts a base32 string and returns an ascii binary string |
||
163 | * |
||
164 | * @param string $str The base32 string to convert |
||
165 | * |
||
166 | * @return string Ascii binary string |
||
167 | * @throws \chillerlan\Base32\Base32Exception |
||
168 | */ |
||
169 | public static function toBin($str){ |
||
192 | |||
193 | /** |
||
194 | * fromString |
||
195 | * |
||
196 | * Convert any string to a base32 string |
||
197 | * This should be binary safe... |
||
198 | * |
||
199 | * @param string $str The string to convert |
||
200 | * |
||
201 | * @return string The converted base32 string |
||
202 | */ |
||
203 | public static function fromString($str){ |
||
206 | |||
207 | /** |
||
208 | * toString |
||
209 | * |
||
210 | * Convert any base32 string to a normal sctring |
||
211 | * This should be binary safe... |
||
212 | * |
||
213 | * @param string $str The base32 string to convert |
||
214 | * |
||
215 | * @return string The normal string |
||
216 | */ |
||
217 | public static function toString($str){ |
||
228 | |||
229 | /** |
||
230 | * @param $str |
||
231 | * |
||
232 | * @throws \chillerlan\Base32\Base32Exception |
||
233 | */ |
||
234 | protected static function checkLength($str){ |
||
239 | |||
240 | /** |
||
241 | * @param $str |
||
242 | * |
||
243 | * @throws \chillerlan\Base32\Base32Exception |
||
244 | */ |
||
245 | protected static function checkBin($str){ |
||
250 | |||
251 | } |
||
252 |