mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vlib.crypto+other: fix mut args
This commit is contained in:
parent
818c4a14e5
commit
511a3d3901
15 changed files with 53 additions and 43 deletions
|
@ -55,14 +55,15 @@ pub fn new() *Digest {
|
|||
return d
|
||||
}
|
||||
|
||||
pub fn (d mut Digest) write(p mut []byte) ?int {
|
||||
pub fn (d mut Digest) write(p_ []byte) ?int {
|
||||
mut p := p_
|
||||
nn := p.len
|
||||
d.len += u64(nn)
|
||||
if d.nx > 0 {
|
||||
n := copy(d.x.right(d.nx), p)
|
||||
d.nx += n
|
||||
if d.nx == BlockSize {
|
||||
block(d, d.x)
|
||||
block(mut d, d.x)
|
||||
d.nx = 0
|
||||
}
|
||||
if n >= p.len {
|
||||
|
@ -73,7 +74,7 @@ pub fn (d mut Digest) write(p mut []byte) ?int {
|
|||
}
|
||||
if p.len >= BlockSize {
|
||||
n := p.len &~ (BlockSize - 1)
|
||||
block(d, p.left(n))
|
||||
block(mut d, p.left(n))
|
||||
if n >= p.len {
|
||||
p = []byte
|
||||
} else {
|
||||
|
@ -107,7 +108,7 @@ pub fn (d mut Digest) checksum() []byte {
|
|||
tmp[0] = 0x80
|
||||
pad := (55 - int(d.len)) % 64 // calculate number of padding bytes
|
||||
binary.little_endian_put_u64(mut tmp.right(1+pad), u64(d.len<<u64(3))) // append length in bits
|
||||
d.write(mut tmp.left(1+pad+8))
|
||||
d.write(tmp.left(1+pad+8))
|
||||
|
||||
// The previous write ensures that a whole number of
|
||||
// blocks (i.e. a multiple of 64 bytes) have been hashed.
|
||||
|
@ -127,7 +128,7 @@ pub fn (d mut Digest) checksum() []byte {
|
|||
// sum returns the MD5 checksum of the data.
|
||||
pub fn sum(data []byte) []byte {
|
||||
mut d := new()
|
||||
d.write(mut data)
|
||||
d.write(data)
|
||||
return d.checksum()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue