Skip to content

Commit eebd51e

Browse files
committed
docs
1 parent 48bf13b commit eebd51e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

contracts/utils/Base58.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,23 @@ library Base58 {
1616

1717
error InvalidBase56Digit(uint8);
1818

19+
/**
20+
* @dev Base58 encoding and decoding tables
21+
*/
1922
bytes internal constant _TABLE = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2023
bytes internal constant _LOOKUP_TABLE =
2124
hex"000102030405060708ffffffffffffff090a0b0c0d0e0f10ff1112131415ff161718191a1b1c1d1e1f20ffffffffffff2122232425262728292a2bff2c2d2e2f30313233343536373839";
2225

26+
/**
27+
* @dev Encode a `bytes` buffer as a Base58 `string`.
28+
*/
2329
function encode(bytes memory data) internal pure returns (string memory) {
2430
return string(_encode(data));
2531
}
2632

33+
/**
34+
* @dev Decode a Base58 `string` into a `bytes` buffer.
35+
*/
2736
function decode(string memory data) internal pure returns (bytes memory) {
2837
return _decode(bytes(data));
2938
}

contracts/utils/Base64.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ pragma solidity ^0.8.20;
88
*/
99
library Base64 {
1010
/**
11-
* @dev Base64 Encoding/Decoding Table
11+
* @dev Base64 encoding table
1212
* See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
1313
*/
1414
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1515
string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1616

1717
/**
18-
* @dev Converts a `bytes` to its Bytes64 `string` representation.
18+
* @dev Converts a `bytes` to its Base64 `string` representation.
1919
*/
2020
function encode(bytes memory data) internal pure returns (string memory) {
2121
return _encode(data, _TABLE, true);
2222
}
2323

2424
/**
25-
* @dev Converts a `bytes` to its Bytes64Url `string` representation.
25+
* @dev Converts a `bytes` to its Base64Url `string` representation.
2626
* Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
2727
*/
2828
function encodeURL(bytes memory data) internal pure returns (string memory) {

0 commit comments

Comments
 (0)