How to perform inverse operations (decryption function to encryption function)

Source: Internet
Author: User

The function is as follows:

Function Dip (STR: string): string;
VaR
M, str1: string;
ASC, asc1: byte;
I: integer;
Begin
M: = 'asdfdghjvvvacw ';
For I: = 1 to length (STR) Do
Begin
ASC: = ord (STR [I]);
ASC: = ASC and $ F;
Asc1: = ord (M [I]);
Asc1: = asc1 and $ F;
Asc1: = asc xor asc1;
ASC: = ord (STR [I]);
ASC: = ASC and $ F0;
ASC: = ASC + asc1;
Str1: = str1 + CHR (ASC );
End;
Result: = str1;
End;

Call

Edit2.text: = Dip (edit1.text );

The above is the decryption function. When the parameter is '100 (= 0 & 336 (820 ', the returned result is an IP Address: 202.97.246.227

The question is, how to write the encryption function to change this IP address to 336 (= 0 & 820 (166

That is, fun ('1970. 97.246.227 ') = '1970 (= 0 & 202 (100'

**************************************** **************************************** *

This encryption function is reversible,
Dip ('2017 (= 0 & 336 (820 ') = '2017. 97.246.227'

Call it again
Dip ('1970. 97.246.227 ') = '1970 (= 0 & 202 (336'
**************************************** ***********************

Encryption only changes the four-bit lower of the original code and one key, so it is restored when it is different from the same key or

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.