<div dir="ltr">Thanks Jolyon! works a treat now.....glad to not be stuck with Delphi 2007 for this solution !! :-)<div><br></div><div><br></div><div>Thanks, Jeremy</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 27, 2017 at 11:14 AM, Jolyon Direnko-Smith <span dir="ltr"><<a href="mailto:jsmith@deltics.co.nz" target="_blank">jsmith@deltics.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There is nothing that immediately jumps out as suspicious in the code, other than the call into OverByteICS code (which is not shown and so cannot be verified).<br><br>If the problem is that for any given input you are now getting a different MD5 than you did previously, then the problem may simply be that when you has a UnicodeString version of what was previously an ANSIString, then your hash will be different due to the fact simply that the two strings <i>are in fact different</i>.<br><br> Hello#0<div>vs H#0e#0l#0l#0o#0#0#0<br><br><br>i.e. the code is perfectly valid for hashing an ANSIString in a Delphi version where String == ANSIString, and yet is also perfectly valid for hashing a UnicodeString in versions where String == UnicodeString.<br><br>But you will get a different result in each case simply because ANSIString <> UnicodeString.<br><br><br>If that is the case, and you want/need to ensure you are still hashing an ANSIString in Delphi 2010+ then you will need to convert the (Unicode)String to an ANSIString before hashing it.<br><br> - change all your string/char types in the function to ANSIString/ANSIChar<br> - convert the input strings to ANSI </div><div> - process them as ANSI</div><div> - ensure you are using the correct ANSI implementation of OverByte (or possibly look at switching to System.Hash)</div><div> - convert your results back from ANSI to UnicodeString when done (if necessary/appropriate)<br><br><br>hth</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 27 March 2017 at 08:32, Jeremy Coulter <span dir="ltr"><<a href="mailto:jscoulter@gmail.com" target="_blank">jscoulter@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi all. It might be I have been mucking around with this too much and have just simply got confused!<div><br></div><div>I am converting some code from Delphi 2007 to 10.1.</div><div>I am having an issue on D 10.1 with this code which is fin under 2007 and it will be due to the unicode stuff that was introduced.</div><div>Can someone let me know how I would convert this to be 10.1 compatible? I have spent some time on it and not really got any where.</div><div><br></div><div>Thanks, Jeremy</div><div><br></div><div><div>function encode_password(passw, hash: string): string;</div><div>var</div><div> ac, temp: string;</div><div> pc: array of char;</div><div> i, lp: integer;</div><div>begin</div><div> if (hash<>'') and (passw<>'')</div><div> then begin</div><div> lp:=length(passw);</div><div> setlength(pc,1+lp+16);</div><div> pc[0]:=#0;</div><div> move(passw[1],pc[1],lp);</div><div> for i:=0 to 15</div><div> do begin</div><div> ac:=copy(hash,i*2+1,2);</div><div> if ac<>''</div><div> then pc[1+lp+i]:=Chr(StrToInt('$' + ac));</div><div> end;</div><div> temp:=GetMD5(@pc[0], 1+lp+16); //GETMD5 is in the OverByteICS code so should be ok</div><div> end</div><div> else begin</div><div> temp:='#error#';</div><div> end;</div><div> result:=lowercase(temp);</div><div>end;</div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" rel="noreferrer" target="_blank">http://delphi.org.nz/mailman/l<wbr>istinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.<wbr>net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" rel="noreferrer" target="_blank">http://delphi.org.nz/mailman/<wbr>listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.<wbr>net.nz</a> with Subject: unsubscribe<br></blockquote></div><br></div>