Data::UUID::Base64URLSafe - URL-safe UUIDs


Data-UUID-Base64URLSafe documentation Contained in the Data-UUID-Base64URLSafe distribution.

Index


Code Index:

NAME

Top

Data::UUID::Base64URLSafe - URL-safe UUIDs

SYNOPSIS

Top

  use Data::UUID::Base64URLSafe;
  my $ug = Data::UUID::Base64URLSafe->new;
  my $uuid = $ug->create_b64_urlsafe;

DESCRIPTION

Top

Data::UUID creates wonderful Globally/Universally Unique Identifiers (GUIDs/UUIDs). This module is a subclass of that module which adds a method to get a URL-safe Base64-encoded version of the UUID using MIME::Base64::URLSafe. What that means is that you can get a 22-character UUID string which you can use safely in URLs.

METHODS

Top

new

The constructor:

  my $ug = Data::UUID::Base64URLSafe->new;

create_b64_urlsafe

Create a URL-safe Base64-encoded UUID:

  my $uuid = $ug->create_b64_urlsafe;

create_from_name_b64_urlsafe

Creates a URL-safe Base64 encoded UUID with the namespace and data specified (See the Data::UUID docs on create_from_name

from_b64_urlsafe

   my $uuid2 = $ug−>create_from_name_b64_urlsafe(<namespace>, <name>);




to_b64_urlsafe

Convert a binary UUID to a URL-safe Base64 encoded UUID

from_b64_urlsafe

Convert a Base 64-encoded URL-safe UUID to its canonical binary representation

AUTHOR

Top

Leon Brocard, <acme@astray.com>

COPYRIGHT

Top

LICENSE

Top

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.


Data-UUID-Base64URLSafe documentation Contained in the Data-UUID-Base64URLSafe distribution.

package Data::UUID::Base64URLSafe;
use strict;
use warnings;
use MIME::Base64::URLSafe;
use base qw(Data::UUID);
our @EXPORT  = @{Data::UUID::EXPORT};
our $VERSION = '0.34';

sub new {
    my $class = shift;
    my $self  = $class->SUPER::new(@_);
    bless $self, $class;
    return $self;
}

sub create_b64_urlsafe {
    my $self = shift;
    return urlsafe_b64encode( $self->create );
}

sub create_from_name_b64_urlsafe {
    my $self = shift;
    return urlsafe_b64encode( $self->create_from_name(@_) );
}

sub to_b64_urlsafe {
    my $self = shift;
    my $uuid = shift;
    return urlsafe_b64encode($uuid);
}

sub from_b64_urlsafe {
    my $self = shift;
    my $uuid = shift;
    return urlsafe_b64decode($uuid);
}

1;

__END__