For details about how to use php to generate an encrypted zip file, phpmyadmin contains a zip. lib. php file, which can generate a zip file, but cannot be encrypted. The eldest brother knows how to encrypt it? (I am talking about encryption refers to the request to enter the decompression password when extracting the file ). I found a lot on the internet. basically, winrar or zip files are used for command line encryption. Is there any encrypted zip file generated through php? Why can't I select an expert now? I 'd like to ask my eldest brother to check it out... -- About using php to generate encrypted zip files
Phpmyadmin contains a zip. lib. php file that can generate a zip file, but cannot be encrypted. The eldest brother knows how to encrypt it? (I am talking about encryption refers to the request to enter the decompression password when extracting the file ).
I found a lot on the internet. basically, winrar or zip files are used for command line encryption. Is there any encrypted zip file generated through php?
Why can't I select an expert now? I 'd like to ask my eldest brother to check it out...
------ Solution --------------------
Help !!!!!
------ Solution --------------------
1. The existing php functions for zip operations are divided into two categories: ZipArchive and zip, and no password for files is found.
2. the simplest method is to use winrar or zip to encrypt data through the command line.
3. analyze encrypted and unencrypted files and read/write the files. this is not feasible and requires high technical implementation.
------ Solution --------------------
It seems that data cannot be encrypted. encryption is implemented using other technologies.
------ Solution --------------------
You can customize the encryption rules. The most simple character is character encoding, for example, "aaaaa". after encryption, you want to change it to "bbbbb ".
/**
* Passport encryption function
*
* @ Param string the original string waiting for encryption
* @ Param string private key (used for decryption and encryption)
*
* @ Return string the result of the original string encrypted with a private key
*/
Function passport_encrypt ($ txt, $ key)
{
// Use the random number generator to generate 0 ~ 32000 value and MD5 ()
Srand (double) microtime () * 1000000 );
$ Encrypt_key = md5 (rand (0, 32000 ));
// Variable initialization
$ Ctr = 0;
$ Tmp = '';
// For loop, $ I is an integer starting from 0 to less than $ txt string length
For ($ I = 0; $ I <strlen ($ txt); $ I ++)
{
// If $ ctr = $ encrypt_key length, $ ctr is cleared.
$ Ctr = strlen ($ encrypt_key )? 0: $ ctr;
// Add two digits to the end of the $ tmp string. The first part of the string is the $ ctr bit of $ encrypt_key,
// The second part is the $ I bit of $ txt and the $ ctr bit of $ encrypt_key. Then $ ctr = $ ctr + 1
$ Tmp. = $ encrypt_key [$ ctr]. ($ txt [$ I] ^ $ encrypt_key [$ ctr ++]);
}
// Return result. The result is the base65 encoding result returned by the passport_key () function.
Return base64_encode (passport_key ($ tmp, $ key ));
}
/**
* Passport decryption function
*
* @ Param string the encrypted string
* @ Param string private key (used for decryption and encryption)
*
* @ Return string result after private key decryption
*/
Function passport_decrypt ($ txt, $ key)
{
// $ Txt results in base64 decoding of the encrypted string, and then together with the private key,
// Return value after passport_key () function processing
$ Txt = passport_key (base64_decode ($ txt), $ key );
// Variable initialization
$ Tmp = '';
// For loop, $ I is an integer starting from 0 to less than $ txt string length
For ($ I = 0; $ I <strlen ($ txt); $ I ++)
{
// $ Tmp adds a bit at the end of the string, whose content is the $ I bit of $ txt,
// It is the same as the $ I + 1 bits in $ txt. Then $ I = $ I + 1
$ Tmp. = $ txt [$ I] ^ $ txt [++ $ I];
}
// Return the value of $ tmp as the result
Return $ tmp;
}
/**
* Passport key processing function
*
* @ Param string the string to be encrypted or to be decrypted
* @ Param string private key (used for decryption and encryption)
*
* @ Return string the processed key
*/
Function passport_key ($ txt, $ encrypt_key)
{
// Assign $ encrypt_key to the value of $ encrypt_key after md5 ()
$ Encrypt_key = md5 ($ encrypt_key );
// Variable initialization
$ Ctr = 0;
$ Tmp = '';
// For loop, $ I is an integer starting from 0 to less than $ txt string length
For ($ I = 0; $ I <strlen ($ txt); $ I ++)
{
// If $ ctr = $ encrypt_key length, $ ctr is cleared.
$ Ctr = strlen ($ encrypt_key )? 0: $ ctr;
// $ Tmp adds a bit at the end of the string, whose content is the $ I bit of $ txt,
// It is the same or as the $ ctr + 1 of $ encrypt_key. Then $ ctr = $ ctr + 1
$ Tmp. = $ txt [$ I] ^ $ encrypt_key [$ ctr ++];
}
// Return the value of $ tmp as the result
Return $ tmp;
}
/**
* Passport information (array) encoding function
*
* @ Param array the array to be encoded
*
* @ Return string the encoded string of the string array.