Crea un'impronta (hash) di un file in base all'algoritmo passato.
LONG WINAPI dmtHash (
HDMTOBJ hDmt,
char *szFileName,
char *szOutputFileHash = NULL,
char *szOutputHexHash = NULL,
char *szOutputHash = NULL,
long dwAlgHash = DMT_CALG_SHA1,
bool bMinuscole = false);
Public Declare Function dmtHash Lib "Dimatec.dll" _
(ByVal hDmt As Long, _
ByVal szFileName As String, _
Optional ByVal szOutputFileHash As String = vbNullString, _
Optional ByVal szOutputHexHash As String = vbNullString, _
Optional ByVal szOutputHash As String = vbNullString, _
Optional ByVal dwAlgHash As Long = DMT_CALG_SHA1, _
Optional ByVal fMinuscole As Boolean = False) _
As Long
External_Function dmtHash "dmtHash" Dimatec.dll ;
Handle hDmt ;
String szFileName ;
String szOutputFileHash ; // = ""
Address lpOutputHexHash ; // = NULL
Address lpOutputHash ; // = NULL
Integer dwAlgHash ; // = DMT_CALG_SHA1
Boolean fMinuscole ; // = FALSE
Returns Integer
[DllImport("Dimatec.dll")]
public static extern int dmtHash (
int hDmt,
string szFileName,
string szOutputFileHash /*= ""*/,
StringBuilder szOutputHexHash /*= ""*/,
StringBuilder szOutputHash /*= ""*/,
int dwAlgHash /*= DMT_CALG_SHA1*/,
bool fMinuscole /*= false */);
hDmt - Handle dell'oggetto DiMaTek
szFileName - Nome del file da cui creare l'hash
szAlgHash - Identificativo dell'algoritmo di hash da utilizzare [vedi Algoritmi di hash e di cifratura]
bMinuscole - Specifica se nel codice esadecimale dell'hash le lettere devono essere minuscole o maiuscole
szOutputFileHash - File di output che conterrą l'hash
szOutputHexHash - Codice hash tradotto esadecimale
szOutputHash - Codice hash puro
DMT_OK in caso di successo, altrimenti un codice di errore
Integer ret
String sFileToHash
String sFileImpronta
Get psFileToHash of oGeneraImpronta to sFileToHash
Get Label of oTextBox_FileImpronta to sFileImpronta
// Check
If (Length(Trim(psFileToHash(oGeneraImpronta))) = 0) Begin
Send Stop_Box "Non e' stato scelto nessun file da cifrare" "EseguiCifratura"
Procedure_Return
End
Move (dmtHash( ;
ghDmt , ;
sFileToHash , ;
sFileImpronta , ;
0 , ;
0 , ;
DMT_CALG_SHA1 , ;
False)) to ret
if (labelFileToHash.Text.Length == 0)
{
MessageBox.Show(this, "Any file selected to hash", "HashFile",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
StringBuilder szOutputHexHash = new StringBuilder("");
StringBuilder szOutputHash = new StringBuilder("");
int HashResult = CDIMATECLIBRARY.dmtHash(
CDIMATECLIBRARY.ghDimatecObj,
labelFileToHash.Text,
labelHashFileGenerated.Text,
szOutputHexHash,
szOutputHash,
CDIMATECLIBRARY.DMT_CALG_SHA1,
false);