From: Keith Hurst on 6 Feb 2006 04:37 Good stuff, hope it helps. Keith "Urs Eggmann" <UrsEggmann(a)compuserve.com> wrote in message news:44hvnjF2a4ivU1(a)individual.net... > Keith, > Everything arrived OK. Thank you very much > Urs > > "Keith Hurst" <WORKIT(a)OUT__news_AT_kjhurst_DOT_com.COM> schrieb im > Newsbeitrag news:2lGEf.246730$vl2.218315(a)fe2.news.blueyonder.co.uk... > > Urs, > > > > sent you mail, let me know if you get it OK. > > > > Keith > > > > "Urs Eggmann" <UrsEggmann(a)compuserve.com> wrote in message > > news:44ffjhF1v460U1(a)individual.net... > > > Hi Keith, > > > > > > I'm also interested in these prototypes. Where did you get them ? > > > Or can you provide me with a copy? > > > > > > regards > > > Urs > > > > > > "Keith Hurst" <WORKIT(a)OUT__news_AT_kjhurst_DOT_com.COM> schrieb im > > > Newsbeitrag news:1wNBf.201867$vl2.158780(a)fe2.news.blueyonder.co.uk... > > > > Hi, > > > > > > > > we use the freely available AAMD532.DLL. > > > > > > > > Once you have the VO prototypes up and running you can use this to > > > generate > > > > MD5 hash values from files or strings of any length. Been using this > for > > a > > > > few years and not one problem with it. > > > > > > > > Regards > > > > Keith Hurst > > > > > > > > "Alwyn Jennings-Bramly" <alwyn.j-b(a)dsl.pipex.com> wrote in message > > > > news:43pd4rF1ku32fU1(a)individual.net... > > > > > Hi all, > > > > > > > > > > I have seen lots of freeware utilities for creating a "Hash" value > for > > > > files > > > > > using the MD5 standard. > > > > > > > > > > But I only want to do this for a (shortish) string. This is for use > > in > > > a > > > > > CGI app, so no GUI allowed. > > > > > > > > > > Any ideas? > > > > > > > > > > Alwyn > > > > > > > > > > > > > > > > > > > > > > > > > >
From: rui.gominho on 8 Feb 2006 02:29
Hi All, Below the code i am using for MD5, based on Ginny's crypt sessions. You will have to fix the wrap lines HTH Adriano DEFINE CALG_MD5 :=((4 << 13) + (0) + 3) DEFINE CRYPT_NEWKEYSET :=0x00000008 _DLL FUNCTION CryptAcquireContext(phProv AS DWORD PTR, pszContainer AS PSZ,pszProvider AS PSZ, dwProvType AS DWORD, dwFlags AS DWORD) AS LOGIC PASCAL:advapi32.CryptAcquireContextA _DLL FUNCTION CryptCreateHash(hProv AS DWORD, Algid AS DWORD, hKey AS DWORD,dwFlags AS DWORD, phHash AS DWORD PTR) AS LOGIC PASCAL:advapi32.CryptCreateHash _DLL FUNCTION CryptDestroyHash(hHash AS DWORD) AS LOGIC PASCAL:advapi32.CryptDestroyHash _DLL FUNCTION CryptGetHashParam(hHash AS DWORD, dwParam AS DWORD, pbData AS PTR, pdwDataLen AS DWORD PTR, dwFlags AS DWORD) AS LOGIC PASCAL:advapi32.CryptGetHashParam _DLL FUNCTION CryptHashData(hHash AS DWORD, pData AS PTR, dwDataLen AS DWORD, dwFlags AS DWORD) AS LOGIC PASCAL:advapi32.CryptHashData _DLL FUNCTION CryptReleaseContext(hProv AS DWORD, dwFlags AS DWORD) AS LOGIC PASCAL:advapi32.CryptReleaseContext DEFINE HP_HASHSIZE :=0x0004 // Hash value size DEFINE HP_HASHVAL :=0x0002 // Hash value DEFINE PROV_RSA_FULL :=1 FUNCTION MD5(cdata AS STRING,cHashValue REF STRING) AS LOGIC LOCAL lresult AS LOGIC /* De:Ginny Caughey (70714.1741(a)compuserve.com) Assunto:Re: MD5 in VO? Newsgroups:comp.lang.clipper.visual-objects Data:2000-09-19 12:35:03 PST Sligthly adapted by Adriano Rui Gominho // v1.5b 30-Set-2004 17:51:48 */ LOCAL hCryptProvider AS DWORD LOCAL hHash AS DWORD LOCAL dwDataLen AS DWORD LOCAL pHashData AS PTR LOCAL dwHashLen AS DWORD LOCAL cError AS USUAL dwDataLen := Len(cData) BEGIN SEQUENCE // Acquire handle to default provider IF !CryptAcquireContext( ; @hCryptProvider, ; // PTR for CSP NULL_PTR, ; // Container name NULL_PTR, ; // Provider name PROV_RSA_FULL, ; // Provider type 0) // Flags cError := "Could not acquire crypto context." IF !CryptAcquireContext( ; @hCryptProvider, ; // PTR for CSP NULL_PTR, ; // Container name NULL_PTR, ; // Provider name PROV_RSA_FULL, ; // Provider type CRYPT_NEWKEYSET) // Flags cError := "Could not acquire crypto context." BREAK ENDIF ENDIF // MessageBox(0, PSZ("Crypto context acquired"), PSZ("Success"), MB_OK) // Create a hash object IF !CryptCreateHash(; hCryptProvider, ; // CSP provider CALG_MD5, ; // Which hash algorithm 0, ; // Key 0, ; // Must be zero @hHash) // Hash object handle cError := "Could not create hash object" BREAK ENDIF // essageBox(0, PSZ("Hash object created"), PSZ("Success"), MB_OK) // Add the data you want hashed to the hash object IF !CryptHashData(; hHash, ; // Hash object handle String2Psz(cData), ; // Ptr to data dwDataLen, ; // Length of data 0) // Flags cError := "Could not add data to hash object" BREAK ENDIF // MessageBox(0, PSZ("Data added to hash object"), PSZ("Success"), MB_OK) // Get size of hash value and allocate memory for it IF !CryptGetHashParam( ; hHash, ; // Hash object handle HP_HASHSIZE, ; // We want hash size NULL_PTR, ; @dwHashLen, ; // Length filled in here 0) cError := "Could not get hash size" BREAK ENDIF // MessageBox(0, PSZ("Hash size is "+AsString(dwHashLen)), PSZ("Success"),MB_OK) pHashData := MemAlloc(dwHashLen) // Now get hash value IF !CryptGetHashParam( ; hHash, ; // Hash object handle HP_HASHVAL, ; // We want hash value pHashData, ; // Hash value filled in here @dwHashLen, ; // Hash length 0) IF GetLastError() == ERROR_MORE_DATA // Allocate more memory MemFree(pHashData) pHashData := MemAlloc(dwHashLen) IF !CryptGetHashParam( ; hHash, ; // Hash object handle HP_HASHVAL, ; // We want hash value pHashData, ; // Hash value filled in here @dwHashLen, ; // Hash length 0) cError := "Still can't get hash value" BREAK ENDIF ELSE cError := "Could not get hash value" BREAK ENDIF ENDIF // MessageBox(0, PSZ("Hash value is "+Mem2String(pHashData, dwHashLen)),PSZ("Success"), MB_OK) cHashValue:=Mem2String(pHashData, dwHashLen) lresult:=TRUE RECOVER #IFDEF __DEBUG__ MessageBox(0, PSZ(cError), PSZ("Error"), MB_OK) #ENDIF END SEQUENCE // Clean up IF pHashData != NULL_PTR MemFree(pHashData) ENDIF IF hHash > 0 CryptDestroyHash(hHash) ENDIF // Release the CSP IF hCryptProvider > 0 CryptReleaseContext(hCryptProvider, 0) ENDIF RETURN lresult FUNCTION HexMD5(cdata AS STRING,cHashValue REF STRING) AS LOGIC // v1.5b 30-Set-2004 17:58:46 LOCAL lresult AS LOGIC IF MD5(cdata,@cHashValue) cHashValue:=MyAsHexString(cHashValue) cHashValue:=StrTran(cHashValue," ",NULL_STRING) lresult:=TRUE ENDIF RETURN lresult |