2 namespace ParagonIE\ConstantTime;
5 * Copyright (c) 2016 Paragon Initiative Enterprises.
6 * Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in all
16 * copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * @package ParagonIE\ConstantTime
31 abstract class Encoding
34 * RFC 4648 Base32 encoding
39 public static function base32Encode($str)
41 return Base32::encode($str);
45 * RFC 4648 Base32 encoding
50 public static function base32EncodeUpper($str)
52 return Base32::encodeUpper($str);
56 * RFC 4648 Base32 decoding
61 public static function base32Decode($str)
63 return Base32::decode($str);
67 * RFC 4648 Base32 decoding
72 public static function base32DecodeUpper($str)
74 return Base32::decodeUpper($str);
78 * RFC 4648 Base32 encoding
83 public static function base32HexEncode($str)
85 return Base32Hex::encode($str);
90 * RFC 4648 Base32 encoding
95 public static function base32HexEncodeUpper($str)
97 return Base32Hex::encodeUpper($str);
101 * RFC 4648 Base32 decoding
106 public static function base32HexDecode($str)
108 return Base32Hex::decode($str);
112 * RFC 4648 Base32 decoding
117 public static function base32HexDecodeUpper($str)
119 return Base32Hex::decodeUpper($str);
123 * RFC 4648 Base64 encoding
128 public static function base64Encode($str)
130 return Base64::encode($str);
134 * RFC 4648 Base32 decoding
139 public static function base64Decode($str)
141 return Base64::decode($str);
147 * Base64 character set "./[A-Z][a-z][0-9]"
151 public static function base64EncodeDotSlash($src)
153 return Base64DotSlash::encode($src);
157 * Decode from base64 to raw binary
159 * Base64 character set "./[A-Z][a-z][0-9]"
162 * @return bool|string
163 * @throws \RangeException
165 public static function base64DecodeDotSlash($src)
167 return Base64DotSlash::decode($src);
173 * Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
177 public static function base64EncodeDotSlashOrdered($src)
179 return Base64DotSlashOrdered::encode($src);
183 * Decode from base64 to raw binary
185 * Base64 character set "[.-9][A-Z][a-z]" or "./[0-9][A-Z][a-z]"
188 * @return bool|string
189 * @throws \RangeException
191 public static function base64DecodeDotSlashOrdered($src)
193 return Base64DotSlashOrdered::decode($src);
197 * Convert a binary string into a hexadecimal string without cache-timing
200 * @param string $bin_string (raw binary)
203 public static function hexEncode($bin_string)
205 return Hex::encode($bin_string);
209 * Convert a hexadecimal string into a binary string without cache-timing
212 * @param string $hex_string
213 * @return string (raw binary)
214 * @throws \RangeException
216 public static function hexDecode($hex_string)
218 return Hex::decode($hex_string);
222 * Convert a binary string into a hexadecimal string without cache-timing
225 * @param string $bin_string (raw binary)
228 public static function hexEncodeUpper($bin_string)
230 return Hex::encodeUpper($bin_string);
234 * Convert a binary string into a hexadecimal string without cache-timing
237 * @param string $bin_string (raw binary)
240 public static function hexDecodeUpper($bin_string)
242 return Hex::decode($bin_string);