™.. SHA1 - Online Linux Manual PageSection : 3
Updated : 2009-05-23
Source : perl v5.10.1
Note : User Contributed Perl Documentation

NAMEDigest::SHA1 − Perl interface to the SHA−1 algorithm

SYNOPSIS​ # Functional style ​ use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); ​ ​ $digest = sha1($data); ​ $digest = sha1_hex($data); ​ $digest = sha1_base64($data); ​ $digest = sha1_transform($data); ​ ​ ​ # OO style ​ use Digest::SHA1; ​ ​ $sha1 = Digest::SHA1−>new; ​ ​ $sha1−>add($data); ​ $sha1−>addfile(*FILE); ​ ​ $sha1_copy = $sha1−>clone; ​ ​ $digest = $sha1−>digest; ​ $digest = $sha1−>hexdigest; ​ $digest = $sha1−>b64digest; ​ $digest = $sha1−>transform;

DESCRIPTIONThe \*(C`Digest::SHA1\*(C'\fR module allows you to use the \s-1NIST\s0 \s-1SHA\-1\s0 message digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 160−bit ​fingerprint or message digest of the input. In 2005, security flaws were identified in SHA−1, namely that a possible mathematical weakness might exist, indicating that a stronger hash function would be desirable. The Digest::SHA module implements the stronger algorithms in the SHA family. The \*(C`Digest::SHA1\*(C'\fR module provide a procedural interface for simple use, as well as an object oriented interface that can handle messages of arbitrary length and which can read files directly.

FUNCTIONSThe following functions can be exported from the \*(C`Digest::SHA1\*(C'\fR module. No functions are exported by default. sha1($data,...) This function will concatenate all arguments, calculate the SHA−1 digest of this message, and return it in binary form. The returned string will be 20 bytes long. The result of sha1(a, b, c) will be exactly the same as the result of sha1(abc). sha1_hex($data,...) Same as(), but will return the digest in hexadecimal form. The length of the returned string will be 40 and it will only contain characters from this set: '0'..'9' and 'a'..'f'. sha1_base64($data,...) Same as(), but will return the digest as a base64 encoded string. The length of the returned string will be 27 and it will only contain characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and ​'/'. Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded sha1 digests you might want to append the redundant string = to the result. sha1_transform($data) Implements the basic SHA1 transform on a 64 byte block. The $data argument and the returned $digest are in binary form. This algorithm is used in NIST FIPS 186−2

METHODSThe object oriented interface to \*(C`Digest::SHA1\*(C'\fR is described in this section. After a \*(C`Digest::SHA1\*(C'\fR object has been created, you will add data to it and finally ask for the digest in a suitable format. A single object can be used to calculate multiple digests. The following methods are provided: $sha1 = Digest::SHA1−>new The constructor returns a new \*(C`Digest::SHA1\*(C'\fR object which encapsulate the state of the SHA−1 message-digest algorithm. If called as an instance method (i.e. $sha1>new) it will just reset the state the object to the state of a newly created object. No new object is created in this case. $sha1>reset This is just an alias for $sha1>new. $sha1>clone This a copy of the $sha1 object. It is useful when you do not want to destroy the digests state, but need an intermediate value of the digest, e.g. when calculating digests iteratively on a continuous data stream. Example: ​ my $sha1 = Digest::SHA1−>new; ​ while (<>) { ​ $sha1−>add($_); ​ print "Line $.: ", $sha1−>clone−>hexdigest, "\n"; ​ } $sha1>add($data,...) The $data provided as argument are appended to the message we calculate the digest for. The return value is the $sha1 object itself. All these lines will have the same effect on the state of the $sha1 object: ​ $sha1−>add("a"); $sha1−>add("b"); $sha1−>add("c"); ​ $sha1−>add("a")>add("b")>add("c"); ​ $sha1−>add("a", "b", "c"); ​ $sha1−>add("abc"); $sha1>addfile($io_handle) The $io_handle will be read until EOF and its content appended to the message we calculate the digest for. The return value is the $sha1 object itself. The addfile() method will croak() if it fails reading data for some reason. If it croaks it is unpredictable what the state of the $sha1 object will be in. The addfile() method might have been able to read the file partially before it failed. It is probably wise to discard or reset the $sha1 object if this occurs. In most cases you want to make sure that the $io_handle is in ​\*(C`binmode\*(C'\fR before you pass it as argument to the \fIaddfile()\fR method. $sha1>add_bits($data, $nbits) $sha1>add_bits($bitstring) This implementation of SHA−1 only supports byte oriented input so you might only add bits as multiples of 8. If you need bit level support please consider using the \*(C`Digest::SHA\*(C'\fR module instead. The ​add_bits() method is provided here for compatibility with other digest implementations. See Digest for description of the arguments that ​add_bits() take. $sha1>digest Return the binary digest for the message. The returned string will be 20 bytes long. Note that the \*(C`digest\*(C'\fR operation is effectively a destructive, read-once operation. Once it has been performed, the \*(C`Digest::SHA1\*(C'\fR object is automatically \*(C`reset\*(C'\fR and can be used to calculate another digest value. Call $sha1>clone−>digest if you want to calculate the digest without reseting the digest state. $sha1>hexdigest Same as $sha1>digest, but will return the digest in hexadecimal form. The length of the returned string will be 40 and it will only contain characters from this set: '0'..'9' and 'a'..'f'. $sha1>b64digest Same as $sha1>digest, but will return the digest as a base64 encoded string. The length of the returned string will be 27 and it will only contain characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and '/'. The base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded ​SHA−1 digests you might want to append the string = to the result.

SEE ALSODigest, Digest::HMAC_SHA1, Digest::SHA, Digest::MD5 http://www.itl.nist.gov/fipspubs/fip180−1.htm http://en.wikipedia.org/wiki/SHA_hash_functions

COPYRIGHTThis library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. ​ Copyright 1999−2004 Gisle Aas. ​ Copyright 1997 Uwe Hollerbach.

AUTHORSPeter C. Gutmann, Uwe Hollerbach <uh@alumni.caltech.edu>, Gisle Aas <gisle@aas.no>
0
Johanes Gumabo
Data Size   :   24,253 byte
man-Digest::SHA1.3pmBuild   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 179,955
Visitor ID   :     :  
Visitor IP   :   18.191.200.151   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (parse_manual_page_|249|Digest::SHA1.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\| )         (htmlprn|149|Digest::SHA1.3pm|36/37|.el══─{─══. ds --  —  |.el══─{─══. ds -- \|\(em\| )         (parse_manual_page_|249|Digest::SHA1.3pm|41|br══─}─══|'br══─}─══ )         (htmlprn|149|Digest::SHA1.3pm|41|'br══─}─══ |'br══─}─══ )         (rof_nr_x|149|Digest::SHA1.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (rof_unit_scale_px|41|Digest::SHA1.3pm|51/52|F|.ie \nF ══─{─══. de IX )         (rof_if|19|Digest::SHA1.3pm|51/52|\nF|.ie \nF ══─{─══. de IX )         (htmlprn|149|Digest::SHA1.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX )         (rof_escape_sequence|91|Digest::SHA1.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2" )         (parse_manual_page_|249|Digest::SHA1.3pm|57|══─}─══|.══─}─══ )         (htmlprn|149|Digest::SHA1.3pm|57|.══─}─══ |.══─}─══ )         (rof_escape_sequence|91|Digest::SHA1.3pm|163|\*(C`Digest::SHA1\*(C'\fR module allows you to use the \s-1NIST\s0 \s-1SHA\-1\s0 message |The \f(CW\*(C`Digest::SHA1\*(C'\fR module allows you to use the \s-1NIST\s0 \s-1SHA\-1\s0 message )         (rof_escape_sequence|91|Digest::SHA1.3pm|173|\*(C`Digest::SHA1\*(C'\fR module provide a procedural interface for simple |The \f(CW\*(C`Digest::SHA1\*(C'\fR module provide a procedural interface for simple )         (rof_escape_sequence|91|Digest::SHA1.3pm|178|\*(C`Digest::SHA1\*(C'\fR |The following functions can be exported from the \f(CW\*(C`Digest::SHA1\*(C'\fR )         (rof_escape_sequence|91|Digest::SHA1.3pm|211|\*(C`Digest::SHA1\*(C'\fR is described in this |The object oriented interface to \f(CW\*(C`Digest::SHA1\*(C'\fR is described in this )         (rof_escape_sequence|91|Digest::SHA1.3pm|212|\*(C`Digest::SHA1\*(C'\fR object has been created, you will add |section. After a \f(CW\*(C`Digest::SHA1\*(C'\fR object has been created, you will add )         (rof_escape_sequence|91|Digest::SHA1.3pm|220|\*(C`Digest::SHA1\*(C'\fR object which encapsulate |The constructor returns a new \f(CW\*(C`Digest::SHA1\*(C'\fR object which encapsulate )         (rof_escape_sequence|91|Digest::SHA1.3pm|274|\*(C`binmode\*(C'\fR before you pass it as argument to the \fIaddfile()\fR method. |\&\f(CW\*(C`binmode\*(C'\fR before you pass it as argument to the \fIaddfile()\fR method. )         (rof_escape_sequence|91|Digest::SHA1.3pm|285|\*(C`Digest::SHA\*(C'\fR module instead. The |please consider using the \f(CW\*(C`Digest::SHA\*(C'\fR module instead. The )         (rof_escape_sequence|91|Digest::SHA1.3pm|295|\*(C`digest\*(C'\fR operation is effectively a destructive, |Note that the \f(CW\*(C`digest\*(C'\fR operation is effectively a destructive, )         (rof_escape_sequence|91|Digest::SHA1.3pm|296|\*(C`Digest::SHA1\*(C'\fR |read-once operation. Once it has been performed, the \f(CW\*(C`Digest::SHA1\*(C'\fR )         (rof_escape_sequence|91|Digest::SHA1.3pm|297|\*(C`reset\*(C'\fR and can be used to calculate another |object is automatically \f(CW\*(C`reset\*(C'\fR and can be used to calculate another )