OSDN Git Service

トリップ不具合(バタ53からのマージ)
authorh677 <h677>
Sat, 5 Aug 2006 04:59:42 +0000 (04:59 +0000)
committerh677 <h677>
Sat, 5 Aug 2006 04:59:42 +0000 (04:59 +0000)
Trip.pas

index 0c103f6..8ed2577 100644 (file)
--- a/Trip.pas
+++ b/Trip.pas
@@ -33,6 +33,16 @@ function get_2ch_trip(
        const pw : PChar
 ) : string;
 
+{!
+\brief  \83g\83\8a\83b\83v\82Ì\90\90¬\82É\95K\97v\82Èsalt\82Ì\90\90¬
+\parm   pw  salt\82Ì\8c³\82É\82È\82é\83p\83X\83\8f\81[\83h
+\param  salt    \90\90¬\82µ\82½salt\82ª\8ai\94[\82³\82ê\82é (array[0..2] of char)
+}
+procedure get_salt(
+    const pw : PChar;
+    salt : PChar
+);
+
 const
        kCryptInitialTr : CryptOrdering = ( o_data: (
                #58,#50,#42,#34,#26,#18,#10, #2,#60,#52,#44,#36,#28,#20,#12, #4,
@@ -413,18 +423,30 @@ function get_2ch_trip(
 var
        s : CryptData;
        salt : array [0..2] of char;
-
-       i : Integer;
-       len : Integer;
 begin
 
-       salt[ 0 ] := #0;
        if pw[ 0 ] = #0 then
        begin
                Result := '';
                Exit;
        end;
 
+    get_salt( pw, salt );
+
+
+       Result := Copy( crypt_r( pw, salt, s ), 4, 100 );
+
+end;
+
+procedure get_salt(
+    const pw : PChar;
+    salt : PChar
+);
+var
+    i, len : Integer;
+begin
+       salt[ 0 ] := #0;
+
        if pw[ 1 ] <> #0 then
        begin
                if pw[ 2 ] <> #0 then
@@ -438,8 +460,11 @@ begin
                        else
                                salt[ i ] := '.';
 
-                       if Pos( salt[ i ], ':;<=>?@[\\]^_`' ) > 0 then
-                               salt[ i ] := Char( Integer( salt[ i ] ) + 7 );
+            if Pos ( salt[ i ], ':;<=>?@' ) > 0 then begin
+                salt[ i ] := Char( Integer( salt[ i ] ) + 7 );
+            end else if Pos( salt[ i ], '[\\]^_`' ) > 0 then begin
+                               salt[ i ] := Char( Integer( salt[ i ] ) + 6 );
+            end;
                end;
                if len = 1 then
                        salt[ 1 ] := 'H';
@@ -448,9 +473,6 @@ begin
                salt[ 0 ] := 'H';
                salt[ 1 ] := '.';
        end;
-
-       Result := Copy( crypt_r( pw, salt, s ), 4, 100 );
-
 end;
 
 end.