NAME
URI::di - URI scheme for digital signatures
SYNOPSIS
use URI;
$u = URI->new('di:sha-256');
$u->compute('some data');
my $algo = $u->algorithm;
my $b64 = $u->b64digest;
my $hex = $u->hexdigest;
my $bin = $u->digest;
DESCRIPTION
This module implements the di:
URI scheme laid out in draft-hallambaker-digesturi.
compute $DATA [, $ALGO, \%QUERY]
Compute a new di: URI from some data. Since the data objects we're typically interested in hashing tend to be bulky, this method will optionally take GLOB or SCALAR references, even blessed ones if you can be sure they'll behave, that is, globs treated like files and scalars dereferenced. If not, $DATA
can also be a CODE reference as well, with the Digest context as its first argument, enabling you to specify your own behaviour, like this:
my $obj = MyObj->new;
my $di = URI->new('di:sha-256;');
$di->compute(sub { shift->add($obj->as_string) });
# Alternatively:
use URI::di;
my $di = URI::di->compute(sub { shift->add($obj->as_string) });
The algorithms supported are the same as the ones in Digest, which will be coerced to lower-case in the URI. If omitted, the default algorithm is SHA-256, per the draft spec.
Optionally, you can pass in a string or HASH reference which will be appended to the URI. The keys map as they do in URI::QueryParam, and so do the values, which can be either strings or ARRAY references containing strings, to represent multiple values.
algorithm
Retrieves the hash algorithm. This method is read-only, since it makes no sense to change the algorithm of an already-computed hash.
b64digest [$RAW]
Returns the digest encoded in Base64. An optional $RAW
argument will return the digest without first translating from base64url (section 5 in RFC 4648).
Like everything else in this module that pertains to the hash itself, this accessor is read-only.
hexdigest
Returns the hexadecimal cryptographic digest we're all familiar with.
digest
Retrieves a binary digest, in keeping with the nomenclature in Digest.
locators
Gets or sets the locators defined in section 2.1.4 as URI objects.
crypto
Returns the cryptography spec embedded in the enc
or menc
parameters. A key is kind of a weird thing to embed in a URI, but whatever floats your boat.
AUTHOR
Dorian Taylor, <dorian at cpan.org>
BUGS
Please report any bugs or feature requests to bug-uri-di at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=URI-di. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc URI::di
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2012 Dorian Taylor.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
L<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.