PowerBuilder
PowerBuilder
Hash File: SHA-1, HAVAL, MD2, MD5, SHA-256, SHA-384, SHA-512
See more Encryption Examples
Computing the hash for a file of any size.Chilkat PowerBuilder Downloads
integer li_rc
oleobject loo_Crypt
string ls_Filename
string ls_Hash
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
if li_rc < 0 then
destroy loo_Crypt
MessageBox("Error","Connecting to COM object failed")
return
end if
// Any type of file may be hashed.
// There is no size limitation because the file is consumed
// in streaming mode internally.
ls_Filename = "something.zip"
loo_Crypt.HashAlgorithm = "sha1"
loo_Crypt.EncodingMode = "hex"
// Other possible EncodingMode settings are:
// "quoted-printable", "base64", "base32", and "url"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "SHA1:"
Write-Debug ls_Hash
// Hash using MD2
loo_Crypt.HashAlgorithm = "md2"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "MD2:"
Write-Debug ls_Hash
// Hash using MD5
loo_Crypt.HashAlgorithm = "md5"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "MD5:"
Write-Debug ls_Hash
// Hash using SHA-256
loo_Crypt.HashAlgorithm = "sha256"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "SHA256:"
Write-Debug ls_Hash
// Hash using SHA-384
loo_Crypt.HashAlgorithm = "sha384"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "SHA384:"
Write-Debug ls_Hash
// Hash using SHA-512
loo_Crypt.HashAlgorithm = "sha512"
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "SHA512:"
Write-Debug ls_Hash
// Hash using HAVAL
// There are two additional properties relevant to HAVAL:
// HavalRounds, and KeyLength.
// HavalRounds can have values of 3, 4, or 5.
// KeyLength can have values of 128, 160, 192, 224, or 256
loo_Crypt.HashAlgorithm = "haval"
loo_Crypt.HavalRounds = 5
loo_Crypt.KeyLength = 256
ls_Hash = loo_Crypt.HashFileENC(ls_Filename)
Write-Debug "Haval:"
Write-Debug ls_Hash
destroy loo_Crypt