LOCAL GetCertificatePassword(PassWordIn : Text[30]) HashedPassWordOut : Text[30] TempBlob.INIT; TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEOUTSTREAM(OStream); BigTextVar.ADDTEXT(PassWordIn); BigTextVar.WRITE(OStream); TempBlob.INSERT; TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEINSTREAM(IStream); MD5 := MD5.Create; MyText:= BitCon.ToString(MD5.ComputeHash(IStream)); TempBlob.MODIFY; TempBlob.CALCFIELDS(Blob); //I get the answer back in My Text correct values as per step 2 above but in hexadecimal form "AA-FE-23" etc. //Loop below converts back to dec from hex. ICounter := 0; WHILE MyText <> '' DO BEGIN IPosition := STRPOS(MyText,'-'); ICounter += 1; IF IPosition = 0 THEN BEGIN MyText2[ICounter] := HexToInt(MyText); MyText := ''; END ELSE BEGIN MyText2[ICounter] := HexToInt(COPYSTR(MyText,1,IPosition-1)); MyText := COPYSTR(MyText,IPosition+1); END; END; CLEAR(TempBlob.Blob); TempBlob.MODIFY; TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEOUTSTREAM(OStream); //OStream.WRITE(MyText2); OStream.WRITETEXT(MyText2); TempBlob.MODIFY; TempBlob.CALCFIELDS(Blob); TempBlob.Blob.CREATEINSTREAM(IStream); HashedPassWordOut := ToBase64String(IStream); EXIT(HashedPassWordOut); //Function to convert base 16 to 10 LOCAL HexToInt(HexText : Text[50]) Result : Integer HexDigits := '0123456789ABCDEF'; Result := 0; WHILE HexText <> '' DO BEGIN Result := Result * 16; intVal := STRPOS(HexDigits,COPYSTR(HexText,1,1)) - 1; Result := Result + intVal; HexText := COPYSTR(HexText,2); END; EXIT(Result); //Function to perform 64 bit encoding, this is just the function from TempBlob ToBase64String(IStream : InStream) : Text MemoryStream := MemoryStream.MemoryStream; COPYSTREAM(MemoryStream,IStream); Base64String := Convert.ToBase64String(MemoryStream.ToArray); MemoryStream.Close; EXIT(Base64String);
Answers
TempBlob.Blob.CREATEOUTSTREAM(OStream);
FOR ICounter := 1 TO EndCount DO
OStream.WRITE(MyByte[ICounter]);
//OStream.WRITETEXT(MyText2); //old code
TempBlob.MODIFY;
TempBlob.CALCFIELDS(Blob);
TempBlob.Blob.CREATEINSTREAM(IStream);
HashedPassWordOut := ToBase64String(IStream);
Just wondering if you would know how to convert base64-encoded byte array into a PDF please.
Thanks