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
30 * This class conforms strictly to the RFC
32 * @package ParagonIE\ConstantTime
34 abstract class RFC4648
37 * RFC 4648 Base64 encoding
44 public function base64Encode($str)
46 return Base64::encode($str);
50 * RFC 4648 Base64 decoding
57 public function base64Decode($str)
59 return Base64::decode($str);
63 * RFC 4648 Base64 (URL Safe) encoding
70 public function base64UrlSafeEncode($str)
72 return Base64UrlSafe::encode($str);
76 * RFC 4648 Base64 (URL Safe) decoding
83 public function base64UrlSafeDecode($str)
85 return Base64UrlSafe::decode($str);
89 * RFC 4648 Base32 encoding
96 public function base32Encode($str)
98 return Base32::encodeUpper($str);
102 * RFC 4648 Base32 encoding
104 * "MZXW6===" -> "foo"
109 public function base32Decode($str)
111 return Base32::decodeUpper($str);
115 * RFC 4648 Base32-Hex encoding
117 * "foo" -> "CPNMU==="
122 public function base32HexEncode($str)
124 return Base32::encodeUpper($str);
128 * RFC 4648 Base32-Hex decoding
130 * "CPNMU===" -> "foo"
135 public function base32HexDecode($str)
137 return Base32::decodeUpper($str);
141 * RFC 4648 Base16 decoding
148 public function base16Encode($str)
150 return Hex::encodeUpper($str);
154 * RFC 4648 Base16 decoding
161 public function base16Decode($str)
163 return Hex::decode($str);