Subject | IBO for D2009: 'Password not stored correctly' problem - The Fix. |
---|---|

Author | m. Th. |

Post date | 2009-07-25T16:39:08Z |

In fact both JumbleStringEx & UnJumbleString were broken and

incompatible with the previous versions. IOW, if one would open an older

.dfm (eg. from D2007) the things got screwed.

In order to fix it, one must go in IB_Utils.pas and do the following

changes:

1. Change in the following declarations the 'String' to 'AnsiString':

function JumbleStringEx( Value, KeyPhrase: AnsiString; Alg: integer ):

AnsiString; //mTh ~

{: See description of JumbleString function for details. }

function UnJumbleString( Value, KeyPhrase: AnsiString ): AnsiString; //mTh ~

2. In the 'implementation' section, we change the JumbleStringEx as follows:

(snipped the uninteresting parts. The changed lines are marked with //mTh ~)

function JumbleStringEx( Value, KeyPhrase: AnsiString; Alg: integer ):

AnsiString; //mTh ~

var

tmpStr: ansistring; //mTh ~

ii, jj: integer;

begin

...

//snipped

...

if Alg = 1 then begin

tmpStr := '';

jj := 1;

for ii := 1 to Length( Value ) do begin

tmpStr := tmpStr + AnsiChar( Ord(Value[ii]) XOR

Ord(KeyPhrase[jj]) ); //mTh ~

Inc( jj );

if jj > Length( KeyPhrase ) then

jj := 1;

end;

// Convert the result to a string of hex for safer storage and

useage

tmpStr := BinaryToHexText( PAnsiChar(tmpStr), Length(tmpStr) );

//mTh~ : PAnsiChar

Result := JumblePrefix_v01 + tmpStr;

end // Alg = 1

...

//snipped

...

3. In the 'implementation' section, we change the UnJumbleString as follows:

(snipped the uninteresting parts. The changed lines are marked with //mTh ~)

function UnJumbleString( Value, KeyPhrase: AnsiString ): AnsiString; //mTh ~

var

tmpStr: AnsiString; //mTh~

ii, jj: integer;

begin

...

//snipped

...

if Length( Result ) > 0 then begin

tmpStr := StringOfChar( 'A', Length(Result) div 2 );

HexTextToBinary( Result, PAnsiChar(tmpStr), Length( tmpStr ) );

//mTh ~ (PAnsiChar)

...

//snipped

...

4. Rebuild the packages. Beware at dependencies. A 'brute force'

technique is to try to rebuild twice if for the 1st time it doesn't work.

Tested with IBO 4.3.9 Beta & D2009 Upd3+4 applied. If someone has

problems, please drop a line.

HTH,

m. Th.

incompatible with the previous versions. IOW, if one would open an older

.dfm (eg. from D2007) the things got screwed.

In order to fix it, one must go in IB_Utils.pas and do the following

changes:

1. Change in the following declarations the 'String' to 'AnsiString':

function JumbleStringEx( Value, KeyPhrase: AnsiString; Alg: integer ):

AnsiString; //mTh ~

{: See description of JumbleString function for details. }

function UnJumbleString( Value, KeyPhrase: AnsiString ): AnsiString; //mTh ~

2. In the 'implementation' section, we change the JumbleStringEx as follows:

(snipped the uninteresting parts. The changed lines are marked with //mTh ~)

function JumbleStringEx( Value, KeyPhrase: AnsiString; Alg: integer ):

AnsiString; //mTh ~

var

tmpStr: ansistring; //mTh ~

ii, jj: integer;

begin

...

//snipped

...

if Alg = 1 then begin

tmpStr := '';

jj := 1;

for ii := 1 to Length( Value ) do begin

tmpStr := tmpStr + AnsiChar( Ord(Value[ii]) XOR

Ord(KeyPhrase[jj]) ); //mTh ~

Inc( jj );

if jj > Length( KeyPhrase ) then

jj := 1;

end;

// Convert the result to a string of hex for safer storage and

useage

tmpStr := BinaryToHexText( PAnsiChar(tmpStr), Length(tmpStr) );

//mTh~ : PAnsiChar

Result := JumblePrefix_v01 + tmpStr;

end // Alg = 1

...

//snipped

...

3. In the 'implementation' section, we change the UnJumbleString as follows:

(snipped the uninteresting parts. The changed lines are marked with //mTh ~)

function UnJumbleString( Value, KeyPhrase: AnsiString ): AnsiString; //mTh ~

var

tmpStr: AnsiString; //mTh~

ii, jj: integer;

begin

...

//snipped

...

if Length( Result ) > 0 then begin

tmpStr := StringOfChar( 'A', Length(Result) div 2 );

HexTextToBinary( Result, PAnsiChar(tmpStr), Length( tmpStr ) );

//mTh ~ (PAnsiChar)

...

//snipped

...

4. Rebuild the packages. Beware at dependencies. A 'brute force'

technique is to try to rebuild twice if for the 1st time it doesn't work.

Tested with IBO 4.3.9 Beta & D2009 Upd3+4 applied. If someone has

problems, please drop a line.

HTH,

m. Th.