Subversion Repositories oidplus

Rev

Rev 827 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 827 Rev 874
Line 1... Line 1...
1
<?php
1
<?php
2
declare(strict_types=1);
2
declare(strict_types=1);
3
namespace ParagonIE\ConstantTime;
3
namespace ParagonIE\ConstantTime;
4
 
4
 
-
 
5
use TypeError;
-
 
6
 
5
/**
7
/**
6
 *  Copyright (c) 2016 - 2018 Paragon Initiative Enterprises.
8
 *  Copyright (c) 2016 - 2022 Paragon Initiative Enterprises.
7
 *  Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
9
 *  Copyright (c) 2014 Steve "Sc00bz" Thomas (steve at tobtu dot com)
8
 *
10
 *
9
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
11
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
10
 *  of this software and associated documentation files (the "Software"), to deal
12
 *  of this software and associated documentation files (the "Software"), to deal
11
 *  in the Software without restriction, including without limitation the rights
13
 *  in the Software without restriction, including without limitation the rights
Line 39... Line 41...
39
     *
41
     *
40
     * "foo" -> "Zm9v"
42
     * "foo" -> "Zm9v"
41
     *
43
     *
42
     * @param string $str
44
     * @param string $str
43
     * @return string
45
     * @return string
-
 
46
     *
44
     * @throws \TypeError
47
     * @throws TypeError
45
     */
48
     */
46
    public static function base64Encode(string $str): string
49
    public static function base64Encode(string $str): string
47
    {
50
    {
48
        return Base64::encode($str);
51
        return Base64::encode($str);
49
    }
52
    }
Line 53... Line 56...
53
     *
56
     *
54
     * "Zm9v" -> "foo"
57
     * "Zm9v" -> "foo"
55
     *
58
     *
56
     * @param string $str
59
     * @param string $str
57
     * @return string
60
     * @return string
-
 
61
     *
58
     * @throws \TypeError
62
     * @throws TypeError
59
     */
63
     */
60
    public static function base64Decode(string $str): string
64
    public static function base64Decode(string $str): string
61
    {
65
    {
62
        return Base64::decode($str, true);
66
        return Base64::decode($str, true);
63
    }
67
    }
Line 67... Line 71...
67
     *
71
     *
68
     * "foo" -> "Zm9v"
72
     * "foo" -> "Zm9v"
69
     *
73
     *
70
     * @param string $str
74
     * @param string $str
71
     * @return string
75
     * @return string
-
 
76
     *
72
     * @throws \TypeError
77
     * @throws TypeError
73
     */
78
     */
74
    public static function base64UrlSafeEncode(string $str): string
79
    public static function base64UrlSafeEncode(string $str): string
75
    {
80
    {
76
        return Base64UrlSafe::encode($str);
81
        return Base64UrlSafe::encode($str);
77
    }
82
    }
Line 81... Line 86...
81
     *
86
     *
82
     * "Zm9v" -> "foo"
87
     * "Zm9v" -> "foo"
83
     *
88
     *
84
     * @param string $str
89
     * @param string $str
85
     * @return string
90
     * @return string
-
 
91
     *
86
     * @throws \TypeError
92
     * @throws TypeError
87
     */
93
     */
88
    public static function base64UrlSafeDecode(string $str): string
94
    public static function base64UrlSafeDecode(string $str): string
89
    {
95
    {
90
        return Base64UrlSafe::decode($str, true);
96
        return Base64UrlSafe::decode($str, true);
91
    }
97
    }
Line 95... Line 101...
95
     *
101
     *
96
     * "foo" -> "MZXW6==="
102
     * "foo" -> "MZXW6==="
97
     *
103
     *
98
     * @param string $str
104
     * @param string $str
99
     * @return string
105
     * @return string
-
 
106
     *
100
     * @throws \TypeError
107
     * @throws TypeError
101
     */
108
     */
102
    public static function base32Encode(string $str): string
109
    public static function base32Encode(string $str): string
103
    {
110
    {
104
        return Base32::encodeUpper($str);
111
        return Base32::encodeUpper($str);
105
    }
112
    }
Line 109... Line 116...
109
     *
116
     *
110
     * "MZXW6===" -> "foo"
117
     * "MZXW6===" -> "foo"
111
     *
118
     *
112
     * @param string $str
119
     * @param string $str
113
     * @return string
120
     * @return string
-
 
121
     *
114
     * @throws \TypeError
122
     * @throws TypeError
115
     */
123
     */
116
    public static function base32Decode(string $str): string
124
    public static function base32Decode(string $str): string
117
    {
125
    {
118
        return Base32::decodeUpper($str, true);
126
        return Base32::decodeUpper($str, true);
119
    }
127
    }
Line 123... Line 131...
123
     *
131
     *
124
     * "foo" -> "CPNMU==="
132
     * "foo" -> "CPNMU==="
125
     *
133
     *
126
     * @param string $str
134
     * @param string $str
127
     * @return string
135
     * @return string
-
 
136
     *
128
     * @throws \TypeError
137
     * @throws TypeError
129
     */
138
     */
130
    public static function base32HexEncode(string $str): string
139
    public static function base32HexEncode(string $str): string
131
    {
140
    {
132
        return Base32::encodeUpper($str);
141
        return Base32::encodeUpper($str);
133
    }
142
    }
Line 137... Line 146...
137
     *
146
     *
138
     * "CPNMU===" -> "foo"
147
     * "CPNMU===" -> "foo"
139
     *
148
     *
140
     * @param string $str
149
     * @param string $str
141
     * @return string
150
     * @return string
-
 
151
     *
142
     * @throws \TypeError
152
     * @throws TypeError
143
     */
153
     */
144
    public static function base32HexDecode(string $str): string
154
    public static function base32HexDecode(string $str): string
145
    {
155
    {
146
        return Base32::decodeUpper($str, true);
156
        return Base32::decodeUpper($str, true);
147
    }
157
    }
Line 151... Line 161...
151
     *
161
     *
152
     * "foo" -> "666F6F"
162
     * "foo" -> "666F6F"
153
     *
163
     *
154
     * @param string $str
164
     * @param string $str
155
     * @return string
165
     * @return string
-
 
166
     *
156
     * @throws \TypeError
167
     * @throws TypeError
157
     */
168
     */
158
    public static function base16Encode(string $str): string
169
    public static function base16Encode(string $str): string
159
    {
170
    {
160
        return Hex::encodeUpper($str);
171
        return Hex::encodeUpper($str);
161
    }
172
    }