Handbook
Glossary
add-checksum-bytes ( checksum-state data -- checksum-state )
Factor handbook
»
Input and output
»
Checksums
Prev:
initialize-checksum-state ( checksum -- checksum-state )
Next:
add-checksum-stream ( checksum-state stream -- checksum-state )
Vocabulary
checksums
Inputs
checksum-state
an
object
data
an
object
Outputs
checksum-state
an
object
Definition
IN:
checksums
GENERIC#:
add-checksum-bytes
1
( checksum-state data -- checksum-state )
Methods
USING:
accessors
byte-vectors
checksums
checksums.common
grouping
kernel
math
sequences
;
M::
block-checksum-state
add-checksum-bytes
( state data -- checksum-state )
state
block-size>>
:>
block-size state
bytes>>
length
:>
initial-len initial-len data
length
+
block-size
/mod
:>
( n extra ) data state
bytes>>
[
push-all
]
keep
:>
all-bytes all-bytes block-size
<groups>
extra
zero?
[
f
]
[
unclip-last-slice
]
if
:>
( blocks remain ) state
[
initial-len
-
]
change-bytes-read
drop
blocks
[
state
[
block-size
+
]
change-bytes-read
checksum-block
]
each
state
[
extra
+
]
change-bytes-read
remain
[
>byte-vector
]
[
BV{
}
clone
]
if*
>>bytes
;
USING:
accessors
checksums
kernel
sequences
;
M:
checksum-state
add-checksum-bytes
over
bytes>>
push-all
;
USING:
accessors
checksums
checksums.openssl.private
kernel
openssl
openssl.libcrypto
sequences
;
M:
evp-md-context
add-checksum-bytes
[
dup
handle>>
]
dip
dup
length
EVP_DigestUpdate
ssl-error
;
USING:
accessors
checksums
checksums.multi
kernel
sequences
;
M:
multi-state
add-checksum-bytes
[
add-checksum-bytes
]
curry
[
map!
]
curry
change-states
;
USING:
accessors
checksums
checksums.process
io
kernel
;
M:
process-state
add-checksum-bytes
over
process>>
stream-write
;