Checksum


Object Hierarchy:

GLib.Checksum GLib.Checksum GLib.Checksum

Description:

[ Compact ]
[ Version ( since = "2.16" ) ]
[ CCode ( free_function = "g_checksum_free" , type_id = "G_TYPE_CHECKSUM" ) ]
public class Checksum

An opaque structure representing a checksumming operation.

To create a new GChecksum, use Checksum. To free a GChecksum, use g_checksum_free.

Example: Compute the checksum of a file:

public static int main (string[] args) {
Checksum checksum = new Checksum (ChecksumType.MD5);

FileStream stream = FileStream.open (args[0], "rb");
uint8 fbuf[100];
size_t size;

while ((size = stream.read (fbuf)) > 0) {
checksum.update (fbuf, size);
}

unowned string digest = checksum.get_string ();
print ("%s: %s\n", args[0], digest);
return 0;
}

valac --pkg glib-2.0 GLib.Checksum.vala

Namespace: GLib
Package: glib-2.0

Content:

Static methods:

Creation methods:

Methods:




2022 vala-language.org