File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,23 @@ library Base58 {
16
16
17
17
error InvalidBase56Digit (uint8 );
18
18
19
+ /**
20
+ * @dev Base58 encoding and decoding tables
21
+ */
19
22
bytes internal constant _TABLE = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz " ;
20
23
bytes internal constant _LOOKUP_TABLE =
21
24
hex "000102030405060708ffffffffffffff090a0b0c0d0e0f10ff1112131415ff161718191a1b1c1d1e1f20ffffffffffff2122232425262728292a2bff2c2d2e2f30313233343536373839 " ;
22
25
26
+ /**
27
+ * @dev Encode a `bytes` buffer as a Base58 `string`.
28
+ */
23
29
function encode (bytes memory data ) internal pure returns (string memory ) {
24
30
return string (_encode (data));
25
31
}
26
32
33
+ /**
34
+ * @dev Decode a Base58 `string` into a `bytes` buffer.
35
+ */
27
36
function decode (string memory data ) internal pure returns (bytes memory ) {
28
37
return _decode (bytes (data));
29
38
}
Original file line number Diff line number Diff line change @@ -8,21 +8,21 @@ pragma solidity ^0.8.20;
8
8
*/
9
9
library Base64 {
10
10
/**
11
- * @dev Base64 Encoding/Decoding Table
11
+ * @dev Base64 encoding table
12
12
* See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
13
13
*/
14
14
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ " ;
15
15
string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_ " ;
16
16
17
17
/**
18
- * @dev Converts a `bytes` to its Bytes64 `string` representation.
18
+ * @dev Converts a `bytes` to its Base64 `string` representation.
19
19
*/
20
20
function encode (bytes memory data ) internal pure returns (string memory ) {
21
21
return _encode (data, _TABLE, true );
22
22
}
23
23
24
24
/**
25
- * @dev Converts a `bytes` to its Bytes64Url `string` representation.
25
+ * @dev Converts a `bytes` to its Base64Url `string` representation.
26
26
* Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
27
27
*/
28
28
function encodeURL (bytes memory data ) internal pure returns (string memory ) {
You can’t perform that action at this time.
0 commit comments