Home > Back-end >  C # code, someone to translated into Delphi code?
C # code, someone to translated into Delphi code?

Time:10-01

using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;

The namespace ConsoleApplication2
{
Class Program
{
The static void Main (string [] args)
{
Int privitekey=1234;
The Random RND=new Random (privitekey);
Var PasswordTable=Enumerable. Range (0, 65536). The Select (x=& gt; New {x, o=RND. Next ()})
OrderBy (x=& gt; X.o.). Select ((x, I)=& gt; New {7.0.x.x, I}). ToDictionary (x=& gt; X.i, x=& gt; 7.0.x.x);
Var OrgnTable=PasswordTable. ToDictionary (x=& gt; X.V alue, x=& gt; X.K ey);
Int [] nums={33215, 40127, 53120, 20899, 18088, 18089, 19000, 534};
The foreach (var num nums in)
{
Console. WriteLine (" {000} 0:00 - & gt; {000} 1:00, "num, PasswordTable (num));
}
Int [] encryptnums={4083, 1527, 34515, 35290, 6028, 7709, 63569, 15521};
The foreach (var num in encryptnums)
{
Console. WriteLine (" {000} 0:00 & lt; - {000} 1:00, "num, OrgnTable (num));
}
}
}

CodePudding user response:

//must first understand the meaning of this code, the second loop shows the array numerical random number is opposite output
 
The program Project1.

{$APPTYPE CONSOLE}

USES the
SysUtils, Classes, StrUtils;
Var
I: Integer;
OrgnTable PasswordTable, slist: TStringList;
Encryptnums: array [8] 1.. of integer;
Nums: array [8] 1.. of integer;
STR: string;
The begin
PasswordTable:=TStringList. Create;
OrgnTable:=TStringList. Create;
Slist:=TStringList. Create;
//value corresponding to the random number generated
For I:=0 to 65536 do
The begin
Randomize.
PasswordTable. AddObject (IntToStr (I), TObject (Random (65536)));
Slist. Add (IntToStr (I) + '- & gt; '+ inttostr (Integer (PasswordTable Objects [I])));
end;
//save the d disk
Slist. SaveToFile (' D: \ AA. TXT);
//random number and numerical intermodulation position
For I:=0 to PasswordTable. Do the Count - 1
The begin
OrgnTable. AddObject (IntToStr (Integer (PasswordTable Objects [I])), TObject (I));
end;

Nums [1] :=33215; Nums [2] :=40127; Nums [3] :=53120; Nums [4] :=20899;
Nums [5] :=18088; Nums [6] :=18089; Nums [7] :=19000; Nums [8] :=534;

Encryptnums [1] :=4083; Encryptnums [2] :=1527; Encryptnums [3] :=34515; Encryptnums [4] :=35290;
Encryptnums [5] :=6028; Encryptnums [6] :=7709; Encryptnums [7] :=63569; Encryptnums [8] :=15521;

Writeln (' corresponding random numerical display character ');
For I:=1 to 8 do
The begin
STR:=RightStr (' 00000 '+ IntToStr (Integer (nums [I])), 5) +' - & gt; '+ RightStr (' 00000' + IntToStr (Integer (PasswordTable. Objects [nums [I]])), 5);
Writeln (STR);
end;
Writeln (' characters display random number);
For I:=1 to 8 do
The begin
Writeln (RightStr (' 00000 '+ IntToStr (Integer (encryptnums [I])), 5) +' - & gt; '+ RightStr (' 00000' + IntToStr (Integer (OrgnTable. Objects [encryptnums [I]])), 5))
end;
Readln;
//int privitekey=1234;
//the Random RND=new Random (privitekey);
//var PasswordTable=Enumerable. Range (0, 65536). The Select (x=& gt; New {x, o=RND. Next ()})
//OrderBy (x=& gt; X.o.). Select ((x, I)=& gt; New {7.0.x.x, I}). ToDictionary (x=& gt; X.i, x=& gt; 7.0.x.x);
//var OrgnTable=PasswordTable. ToDictionary (x=& gt; X.V alue, x=& gt; X.K ey);
//int [] nums={33215, 40127, 53120, 20899, 18088, 18089, 19000, 534};
//foreach (var num nums in)
//{
//the Console. WriteLine (" {000} 0:00 - & gt; {000} 1:00, "num, PasswordTable (num));
//}
//int [] encryptnums={4083, 1527, 34515, 35290, 6028, 7709, 63569, 15521};
//foreach (var num in encryptnums)
//{
//the Console. WriteLine (" {000} 0:00 & lt; - {000} 1:00, "num, OrgnTable (num));
//}
//the Console. The Read ();
End.

CodePudding user response:

Admire the
  • Related