| 1 | package Myriad::Util::UUID; | ||
| 2 | |||
| 3 | 17 | our $VERSION = '1.001'; # VERSION | |
| 4 | 17 | our $AUTHORITY = 'cpan:DERIV'; # AUTHORITY | |
| 5 | |||
| 6 | 17 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 17 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 17 | ▶ | use Math::Random::Secure; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 0 | ▶ | sub uuid { |
|
Subroutine
uuid: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 12 | # UUIDv4 (random) | ||
| 13 | 0 | my @rand = map Math::Random::Secure::irand(2**32), 1..4; | |
| 14 | 0 | return sprintf '%08x-%04x-%04x-%04x-%04x%08x', | |
| 15 | $rand[0], | ||
| 16 | $rand[1] & 0xFFFF, | ||
| 17 | (($rand[1] & 0x0FFF0000) >> 16) | 0x4000, | ||
| 18 | $rand[2] & 0xBFFF, | ||
| 19 | ($rand[2] & 0xFFFF0000) >> 16, | ||
| 20 | $rand[3]; | ||
| 21 | } | ||
| 22 | |||
| 23 | 17 | 1; | |
| 24 | |||
| 25 | =head1 AUTHOR | ||
| 26 | |||
| 27 | Deriv Group Services Ltd. C<< DERIV@cpan.org >>. | ||
| 28 | |||
| 29 | See L<Myriad/CONTRIBUTORS> for full details. | ||
| 30 | |||
| 31 | =head1 LICENSE | ||
| 32 | |||
| 33 | Copyright Deriv Group Services Ltd 2020-2022. Licensed under the same terms as Perl itself. | ||
| 34 | |||