{"size": 2344, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/file/scribblings/sha1.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "pkgs/racket-doc/file/scribblings/sha1.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "pkgs/racket-doc/file/scribblings/sha1.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 3, "avg_line_length": 30.4415584416, "max_line_length": 76, "alphanum_fraction": 0.6510238908}
#lang scribble/doc
@(require "common.rkt" scribble/eval (for-label file/sha1))

@(define sha1-eval (make-base-eval))
@interaction-eval[#:eval sha1-eval (require file/sha1)]

@title[#:tag "sha1b"]{SHA1 Message Digest}

@defmodule[file/sha1]

See @racketmodname[openssl/sha1] for a faster implementation.

@defproc[(sha1 [in (or/c bytes? input-port?)]
               [start exact-nonnegative-integer? 0]
               [end (or/c #f exact-nonnegative-integer?) #f])
         string?]{

Returns a 40-character string that represents the SHA-1 hash (in
hexadecimal notation) of the content from @racket[in]. The
@racket[in], @racket[start], and @racket[end] arguments are treated
the same as @racket[sha1-bytes] from @racketmodname[racket/base].

The @racket[sha1] function composes @racket[bytes->hex-string] with
@racket[sha1-bytes].

@examples[
#:eval sha1-eval
(sha1 (open-input-bytes #"abc"))
]

@history[#:changed "7.0.0.5" @elem{Allowed a byte string as @racket[in]
                                   and added the @racket[start] and
                                   @racket[end] arguments.}]}

@defproc[#:link-target? #f
         (sha1-bytes [in (or/c bytes? input-port?)]
                     [start exact-nonnegative-integer? 0]
                     [end (or/c #f exact-nonnegative-integer?) #f])
         bytes?]{

The same as @racket[sha1-bytes] from @racketmodname[racket/base],
returns a 20-byte byte string that represents the SHA-1 hash of the
content from @racket[in].

@examples[
#:eval sha1-eval
(sha1-bytes (open-input-bytes #"abc"))
]

@history[#:changed "7.0.0.5" @elem{Allowed a byte string as @racket[in]
                                   and added the @racket[start] and
                                   @racket[end] arguments.}]}

@defproc[(bytes->hex-string [bstr bytes?]) string?]{

Converts the given byte string to a string representation, where each
byte in @racket[bstr] is converted to its two-digit hexadecimal
representation in the resulting string.

@examples[
#:eval sha1-eval
(bytes->hex-string #"turtles")
]}

@defproc[(hex-string->bytes [str string?]) bytes?]{

Converts the given string to a byte string, where each pair of characters in
@racket[str] is converted to a single byte in the result.

@examples[
#:eval sha1-eval
(hex-string->bytes "70")
(hex-string->bytes "Af")
]}

@close-eval[sha1-eval]
