-
-
Notifications
You must be signed in to change notification settings - Fork 365
Expand file tree
/
Copy pathRandomID.php
More file actions
30 lines (27 loc) · 904 Bytes
/
RandomID.php
File metadata and controls
30 lines (27 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* SPDX-License-Identifier: MIT
* Copyright (c) 2017-2018 Tobias Reich
* Copyright (c) 2018-2025 LycheeOrg.
*/
namespace App\Constants;
class RandomID
{
/**
* The length of the random, character-based ID.
*
* The ID is a random byte sequence encoded as Base64.
* 24 characters means 3/4 * 24 = 18 bytes, i.e. 144 bits of randomness.
* 144 bits (>128 bit) of randomness are considered sufficient to only
* allow for a small chance to guess an ID.
* The length must be divisible by 4 as otherwise the Base64 encoding
* uses the character `=` for padding which must not be used within a URL.
* We use Base64 encoding (instead of an encoding with hex digits),
* because Base64 encoding is more space efficient and also more time
* efficient when used as a primary ID in a database.
*
* @var int
*/
public const ID_LENGTH = 24;
public const ID_TYPE = 'string';
}