كيف اقوم بستغلال الخاصية XorToHex من خلال   function
#1
السلام عليكم  

كيف اقوم بستغلال الخاصية XorToHex من خلال   function


عندى EDIT1  فيه  ‭DC88‬
و EDIT2  تضهر فيه نتيجة  xor    2377

استعملت الكود هذا لكنه خاطى

كود :
procedure TForm3.Button1Click(Sender: TObject); begin   edit2.Text:=XorToHex(edit1.text)); end;





كود :
function XorToHex(const Source: string; Code: char): string; const   HexChars: array[0..15] of char = '0123456789ABCDEF'; var i: Integer;     c: Integer; begin   SetLength(Result,Length(Source)*(sizeof(char)*2));   for i := 1 to Length(Source) do begin     c := Ord(Source[i]) xor Ord(Code);     {$IFDEF UNICODE}     result[i*4-3] := HexChars[(c and 7) shr 4];     result[i*4-2] := HexChars[(c and 7) and 15];     c := c shr 8;     result[i*4-1] := HexChars[c shr 4];     result[i*4]   := HexChars[c and 15];     {$ELSE}     result[i*2-1] := HexChars[c shr 4];     result[i*2]   := HexChars[c and 15];     {$ENDIF}   end; end;
الرد
#2
اسئلتك دائما غامضة ولا تساعد على فهم المشكل

إقتباس :عندى EDIT1  فيه  ‭DC88‬
و EDIT2  تضهر فيه نتيجة  xor    2377

 لاجراء  xor  لابد من عاملين ان كان ‭DC88‬  هو الاول اين الاخر ؟
على كل حال ان كنت تريد اظهار 2377 في EDIT2    معناه انك تقوم بعملية  ‭DC88‬  xor  FFFF


كود :
function XorHex(const Source: string):string; var   I: Integer;   B, Valeur:Byte; begin   Result:= '';   B:=$FF;   for I := 0 to Length(Source)div 2 - 1 do   begin       Valeur := StrToInt('$'+ Copy(Source, I*2+1, 2));       Result:= Result + IntToHex(Valeur xor B, 2);   end; end;
[-] كل من 2 users say قال شكرا ل Ndagor على المشاركة المفيدة
  • ELARAPY, Team dz
الرد


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم