1\docType{methods}
2\name{sha1}
3\alias{sha1}
4\alias{sha1_attr_digest}
5\alias{sha1_digest}
6\alias{sha1.array}
7\alias{sha1.integer}
8\alias{sha1.numeric}
9\alias{sha1.character}
10\alias{sha1.complex}
11\alias{sha1.Date}
12\alias{sha1.factor}
13\alias{sha1.NULL}
14\alias{sha1.logical}
15\alias{sha1.matrix}
16\alias{sha1.data.frame}
17\alias{sha1.list}
18\alias{sha1.pairlist}
19\alias{sha1.name}
20\alias{sha1.POSIXlt}
21\alias{sha1.POSIXct}
22\alias{sha1.anova}
23\alias{sha1.function}
24\alias{sha1.call}
25\alias{sha1.raw}
26\alias{sha1.formula}
27\alias{sha1.(}
28\title{Calculate a SHA1 hash of an object}
29\author{Thierry Onkelinx}
30\usage{
31sha1(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
32\method{sha1}{numeric}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
33\method{sha1}{complex}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
34\method{sha1}{Date}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
35\method{sha1}{matrix}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
36\method{sha1}{data.frame}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
37\method{sha1}{array}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
38\method{sha1}{list}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
39\method{sha1}{pairlist}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
40\method{sha1}{POSIXlt}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
41\method{sha1}{POSIXct}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
42\method{sha1}{anova}(x, digits = 4, zapsmall = 7, ..., algo = "sha1")
43\method{sha1}{function}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
44
45\method{sha1}{formula}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
46\method{sha1}{`(`}(...)
47
48sha1_digest(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
49\method{sha1}{NULL}(...)
50\method{sha1}{name}(...)
51
52sha1_attr_digest(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
53\method{sha1}{call}(...)
54\method{sha1}{character}(...)
55\method{sha1}{factor}(...)
56\method{sha1}{integer}(...)
57\method{sha1}{logical}(...)
58\method{sha1}{raw}(...)
59}
60\arguments{
61\item{x}{the object to calculate the SHA1}
62
63\item{digits}{the approximate number of significant digits in base 10. Will
64be converted to a base 16 equivalent. Defaults to \code{digits = 14}, except for
65sha1.anova where \code{digits = 4}}
66
67\item{zapsmall}{the approximate negative magnitude of the smallest relevant
68digit. Will be converted to a base 2 equivalent. Values smaller than this
69number are equivalent to 0. Defaults to \code{zapsmall = 7}}
70
71\item{...}{If it is the only defined argument, passed to another \code{sha1}
72method.  If other arguments exist, see Details for usage.}
73
74\item{algo}{The hashing algoritm to be used by \code{\link{digest}}. Defaults to
75"sha1"}
76}
77\description{
78Calculate a SHA1 hash of an object. The main difference with
79\code{digest(x, algo = "sha1")} is that \code{sha1()} will give the same hash on
8032-bit and 64-bit systems. Note that the results depends on the setting of
81\code{digits} and \code{zapsmall} when handling floating point numbers. The
82current defaults keep \code{digits} and \code{zapsmall} as large as possible
83while maintaining the same hash on 32 bit and 64 bit systems.
84}
85\details{
86\code{sha1_digest()} is a convenience function for objects where attributes
87cannot be added to apply the \code{digest()} function to its arguments.
88\code{sha1_attr_digest()} is a convenience function for objects where objects
89can be added to generate the hash.  If generating hashes for objects in other
90packages, one of these two functions is recommended for use (typically,
91\code{sha1_attr_digest()}).
92
93Extra arguments:
94
95environment: An optional extra argument for \code{sha1.function} and
96\code{sha1.formula} should be TRUE, FALSE or missing. \code{sha1.function} and
97\code{sha1.formula} will ignore the enviroment of the function only when
98\code{environment = FALSE}.
99}
100\note{
101\code{sha1} gained an \code{algo} argument since version 0.6.15. This allows
102\code{sha1()} to use all hashing algoritms available in \code{digest()}. The
103hashes created with \code{sha1(x)} from digest >= 0.6.15 are identical to
104\code{sha1(x)} from digest <= 0.6.14. The only exceptions are hashes created
105with \code{sha1(x, algo = "sha1")}, they will be different starting from digest
1060.6.15
107
108Until version 0.6.22, \code{sha1} ignored the attributes of the object for
109some classes. This was fixed in version 0.6.23. Use
110\code{options(sha1PackageVersion = "0.6.22")} to get the old behaviour.
111
112Version 0.6.24 and later ignore attributes named \code{srcref}.
113}
114