CryptoSys PKI Pro Manual

Example: Hash.HexFromFile  Hash.HexFromTextFile 

[VB6 equivalent: HASH_HexFromFile]

Dim sDigest As String
Dim sFileName As String

' File to be hashed contains a total of 13 bytes: "hello world" plus CR-LF
' 68 65 6c 6c 6f 20 77 6f 72 6c 64 0d 0a   hello world..

sFileName = "hello.txt"

' Create default hash (SHA1) in binary mode
sDigest = Hash.HexFromFile(sFileName, HashAlgorithm.Sha1)
Console.WriteLine(sDigest.Length & " " & sDigest)
' Use SHA1 in "text" mode
sDigest = Hash.HexFromTextFile(sFileName, HashAlgorithm.Sha1)
Console.WriteLine(sDigest.Length & " " & sDigest)
' Use MD5
sDigest = Hash.HexFromFile(sFileName, HashAlgorithm.Md5)
Console.WriteLine(sDigest.Length & " " & sDigest)
' Use MD5 in "text" mode
sDigest = Hash.HexFromTextFile(sFileName, HashAlgorithm.Md5)
Console.WriteLine(sDigest.Length & " " & sDigest)

See Also:
Hash.HexFromFile Method
Hash.HexFromTextFile Method

[Contents] [Index]

[PREV: Example: Hash.HexFromBytes ...]   [Contents]   [Index]   
   [NEXT: Example: Hash.HexFromHex ...]

Copyright © 2004-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-09-18T10:02:53Z.