Delphi mining algorithm
Publish: 2021-04-17 05:32:23
1. //Note: dataset represents the data set you want to operate on, and
/ / cache is the sum of the values you want to subtract from the record< br />var
cache: Integer; recValue: Integer;< br />begin
cache := 50;
/ / first move the data record to the first
dataset.first
/ / start the loop until the end of the record
repeat
/ / if the number of records in the data set is 0, or the sum of the values to be subtracted has been used up, exit
if (dataset. RecordCount = 0) or (CACHE = 0) then break< br />
recValue := dataset.FieldByName(' Record AsInteger; // Getting data from data set
/ / subtracting by conditions is the core of this problem
if recvalue & gt; Cache then
begin
{if the current record value is greater than the sum of the values to be subtracted, set the value to be subtracted as 0
and use the current record value to subtract the sum of the values to be subtracted
}
recvalue: = recvalue - cache; cache := 0;
end
else
if recvalue = cache then
begin
{this step can be merged into the previous / next step, but for good programming style, it should be kept
if the current record value is equal to the sum of the values to be subtracted, then set the value of both sides as 0}
cache: = 0; recValue := 0;
end
else
begin
{if the current record value is less than the sum of the values to be subtracted, the current value is 0
and the sum of the values to be subtracted is used to subtract the current record value}
cache: = cache - recvalue; recValue := 0;< br /> end;
/ / reflect all changes to the database
dataset.edit< br /> dataset.FieldByName(' Record AsInteger := recValue;< br /> dataset.Post;< br />
dataset.Next; // It's a clich é. Move to the next record. It's important here, or it will & quot; Death (circulation) in it & quot< br /> until dataset.eof; // Judge whether the record is moved to the end
end;
/ / cache is the sum of the values you want to subtract from the record< br />var
cache: Integer; recValue: Integer;< br />begin
cache := 50;
/ / first move the data record to the first
dataset.first
/ / start the loop until the end of the record
repeat
/ / if the number of records in the data set is 0, or the sum of the values to be subtracted has been used up, exit
if (dataset. RecordCount = 0) or (CACHE = 0) then break< br />
recValue := dataset.FieldByName(' Record AsInteger; // Getting data from data set
/ / subtracting by conditions is the core of this problem
if recvalue & gt; Cache then
begin
{if the current record value is greater than the sum of the values to be subtracted, set the value to be subtracted as 0
and use the current record value to subtract the sum of the values to be subtracted
}
recvalue: = recvalue - cache; cache := 0;
end
else
if recvalue = cache then
begin
{this step can be merged into the previous / next step, but for good programming style, it should be kept
if the current record value is equal to the sum of the values to be subtracted, then set the value of both sides as 0}
cache: = 0; recValue := 0;
end
else
begin
{if the current record value is less than the sum of the values to be subtracted, the current value is 0
and the sum of the values to be subtracted is used to subtract the current record value}
cache: = cache - recvalue; recValue := 0;< br /> end;
/ / reflect all changes to the database
dataset.edit< br /> dataset.FieldByName(' Record AsInteger := recValue;< br /> dataset.Post;< br />
dataset.Next; // It's a clich é. Move to the next record. It's important here, or it will & quot; Death (circulation) in it & quot< br /> until dataset.eof; // Judge whether the record is moved to the end
end;
2. CRC, right
there are related encryption methods and codes in Indy control
reference idhashcrc.pas unit
DES is in dcpcryptv2!
there are related encryption methods and codes in Indy control
reference idhashcrc.pas unit
DES is in dcpcryptv2!
3. I don't think so. These algorithms are all C-based
4. if 1 mod N = 0 then
{do something}
else
{do something};
{do something}
else
{do something};
5. Encryption can be modified with a slight revision of codes only to re-operate under Delphi.
const
procere encBuf(was Buf: array of Byte);< br/> was
< i: Integer;< B/ > < d, c: byte;< br/ > *Index: Integer;< br/> start
< c := 0;< br/ > =for i := low(Buf) to High(Buf) do
< Index := i mod 16; < br/ > = DEFAULT_M[Index]; < br/ > = d + c; < br/ > =c := byte(Buf[i];
< c := c xor d; < br/ > < Buf[i] := c;< br/ > < end;< br/> end;
const
< i: Integer;< B/ > < d, c: byte;< br/ > *Index: Integer;< br/> start
< c := 0;< br/ > =for i := low(Buf) to High(Buf) do
< Index := i mod 16; < br/ > = DEFAULT_M[Index]; < br/ > = d + c; < br/ > =c := byte(Buf[i];
< c := c xor d; < br/ > < Buf[i] := c;< br/ > < end;< br/> end;
6. The formula you give has a rule as follows:
function Calc (const n: integer): integer
/ / the parameter n is the last bit you need to calculate. If it goes to 1-2 + 3-4 + 5-6 + 7, n is 7
begin
if (n mod 2) = 0 then / / if n is an even number
begin
result: = - floor (n / 2)// Return the negative n Division 2
end else begin / / if not even
result: = floor ((n + 1) / 2)// Return n + 1 divided by 2
end< br />end;
/ / floor round down. You need to quote math unit
/ / it can be achieved by the first floor circulation, but if it is 1000000, it will be suspended. Setting up a thread is not worth the loss
/ / don't understand the Internet hi me
function Calc (const n: integer): integer
/ / the parameter n is the last bit you need to calculate. If it goes to 1-2 + 3-4 + 5-6 + 7, n is 7
begin
if (n mod 2) = 0 then / / if n is an even number
begin
result: = - floor (n / 2)// Return the negative n Division 2
end else begin / / if not even
result: = floor ((n + 1) / 2)// Return n + 1 divided by 2
end< br />end;
/ / floor round down. You need to quote math unit
/ / it can be achieved by the first floor circulation, but if it is 1000000, it will be suspended. Setting up a thread is not worth the loss
/ / don't understand the Internet hi me
7. There are algorithms, programming should not be too big a problem, with a week to solve, there will be a sense of achievement!
8. Unknown_Error
9. D7 provides string encryption and decryption functions< br />EncdDecd.pas
10. If you only encrypt the number, the encrypted ciphertext is also a number, in fact, you can add an operation. For example, the 123 encryption: with 123 * 564 encryption is 69372, decryption is removed with 69372, with 564 can be, this is the simplest method, you can write this operation more complex!
Hot content