mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
crypto: add missing documentation to all pub functions (#8251)
This commit is contained in:
@@ -54,8 +54,9 @@ pub fn new() &Digest {
|
||||
return d
|
||||
}
|
||||
|
||||
// write writes the contents of `p_` to the internal hash representation.
|
||||
[manualfree]
|
||||
fn (mut d Digest) write(p_ []byte) int {
|
||||
pub fn (mut d Digest) write(p_ []byte) int {
|
||||
nn := p_.len
|
||||
unsafe {
|
||||
mut p := p_
|
||||
@@ -89,7 +90,8 @@ fn (mut d Digest) write(p_ []byte) int {
|
||||
return nn
|
||||
}
|
||||
|
||||
fn (d &Digest) sum(b_in []byte) []byte {
|
||||
// sum returns a copy of the generated sum of the bytes in `b_in`.
|
||||
pub fn (d &Digest) sum(b_in []byte) []byte {
|
||||
// Make a copy of d so that caller can keep writing and summing.
|
||||
mut d0 := *d
|
||||
hash := d0.checksum()
|
||||
@@ -100,6 +102,7 @@ fn (d &Digest) sum(b_in []byte) []byte {
|
||||
return b_out
|
||||
}
|
||||
|
||||
// checksum returns the byte checksum of the `Digest`.
|
||||
fn (mut d Digest) checksum() []byte {
|
||||
mut len := d.len
|
||||
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
|
||||
@@ -123,7 +126,7 @@ fn (mut d Digest) checksum() []byte {
|
||||
return digest
|
||||
}
|
||||
|
||||
// Sum returns the SHA-1 checksum of the data.
|
||||
// sum returns the SHA-1 checksum of the bytes passed in `data`.
|
||||
pub fn sum(data []byte) []byte {
|
||||
mut d := new()
|
||||
d.write(data)
|
||||
@@ -136,14 +139,17 @@ fn block(mut dig Digest, p []byte) {
|
||||
block_generic(mut dig, p)
|
||||
}
|
||||
|
||||
// size returns the size of the checksum in bytes.
|
||||
pub fn (d &Digest) size() int {
|
||||
return size
|
||||
}
|
||||
|
||||
// block_size returns the block size of the checksum in bytes.
|
||||
pub fn (d &Digest) block_size() int {
|
||||
return block_size
|
||||
}
|
||||
|
||||
// hexhash returns a hexadecimal SHA1 hash sum `string` of `s`.
|
||||
pub fn hexhash(s string) string {
|
||||
return sum(s.bytes()).hex()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user