Php custom encryption and decryption program instance. Php user-defined encryption and decryption program instance this article mainly introduces php user-defined encryption and decryption program, the instance analyzes the user-defined encryption and decryption files and related usage, some examples of custom encryption and decryption programs with reference to php
This article mainly introduces php user-defined encryption and decryption programs. The example analyzes user-defined encryption and decryption files and their usage, which has some reference value. For more information, see
This example describes the php custom encryption and decryption program. Share it with you for your reference. The specific analysis is as follows:
PHP3 Cryption is a very easy-to-crack, insecure encryption function and should not be a very important thing to use. although encryption is good, it will not hinder the strict test of sophisticated cracking programs.
But try it... this is a great way to encrypt and decrypt strings. It is bidirectional with many hidden nest functions. You can encrypt or decrypt a password. You can also decrypt or encrypt data multiple times through loops or other methods. The characters in the alphabet also change. All these things allow you to modify and consolidate encryption.
What is the best part? You can encrypt and decrypt a piece of paper and a pencil. This takes a long time, but you don't need a computer nearby to use it. if you have lost code, if you still remember that your technology can be decrypted.
I wrote these features in about an hour, after several unsuccessful and frustrating attempts, and gained a longer time I had no way out. The best way to achieve it that day after success is achieved.
Please note that this will not encrypt/decrypt intangible characters (spaces), such as line breaks (n) or tags (tons )! Sorry, but I tried. if you find a solution, please let me know!
The code is as follows:
$ Ralphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !,. :;?~ @ # $ % ^ & * () _ +-=] [} {/> <"'";
$ Alphabet = $ ralphabet. $ ralphabet;
Class Crypto {
Function encrypt ($ password, $ strtoencrypt ){
Global $ ralphabet;
Global $ alphabet;
For ($ I = 0; $ I {
$ Cur_pswd_ltr = substr ($ password, $ I, 1 );
$ Pos_alpha_ary [] = substr (strstr ($ alphabet, $ cur_pswd_ltr), 0, strlen ($ ralphabet ));
}
$ I = 0;
$ N = 0;
$ Nn = strlen ($ password );
$ C = strlen ($ strtoencrypt );
While ($ I <$ c)
{
$ Encrypted_string. = substr ($ pos_alpha_ary [$ n], strpos ($ ralphabet, substr ($ strtoencrypt, $ I, 1), 1 );
$ N ++;
If ($ n = $ nn) $ n = 0;
$ I ++;
}
Return $ encrypted_string;
}
Function decrypt ($ password, $ strtodecrypt ){
Global $ ralphabet;
Global $ alphabet;
For ($ I = 0; $ I {
$ Cur_pswd_ltr = substr ($ password, $ I, 1 );
$ Pos_alpha_ary [] = substr (strstr ($ alphabet, $ cur_pswd_ltr), 0, strlen ($ ralphabet ));
}
$ I = 0;
$ N = 0;
$ Nn = strlen ($ password );
$ C = strlen ($ strtodecrypt );
While ($ I <$ c)
{
$ Decrypted_string. = substr ($ ralphabet, strpos ($ pos_alpha_ary [$ n], substr ($ strtodecrypt, $ I, 1), 1 );
$ N ++;
If ($ n = $ nn) $ n = 0;
$ I ++;
}
Return $ decrypted_string;
}
Function cryption_table ($ password ){
Global $ ralphabet;
Global $ alphabet;
For ($ I = 0; $ I {
$ Cur_pswd_ltr = substr ($ password, $ I, 1 );
$ Pos_alpha_ary [] = substr (strstr ($ alphabet, $ cur_pswd_ltr), 0, strlen ($ ralphabet ));
}
Print"
N ";Print"
| ";For ($ j = 0; $ j{Print"
". Substr ($ ralphabet, $ j, 1 )." | N ";}Print"
";For ($ I = 0; $ I{Print"
". ($ I + 1)." | | ";For ($ k = 0; $ k{Print"
". Substr ($ pos_alpha_ary [$ I], $ k, 1 )." | N ";}Print"
";}Print"
N ";
}
} // End class Crypto
// Example written by Macro Zeng
$ Ct = new Crypto;
// $ Ct-> cryption_table ($ password );
Echo "";
The code is as follows:
Highlight_file ("crypto. php ");
I hope this article will help you with php programming.
Ghost This article mainly introduces the php custom encryption and decryption program. The example analyzes the custom encryption and decryption files and their usage...