There are 3 things I need to do for a project. First of all, I need a php script to generate a text file. The text file must contain a string generated by a RSA key. What's the best way to generate a hash using RSA keys on PHP?
The second part is that I need to add an icon to this file. The file is supposed to be used on the Mac, but it would be good if the icon worked for Windows and Linux too. I believe I will need to set one icon for the Mac and another one for Windows and Linux. How may I set the icon?
The third thing must be the easiest one, I need to attach the file and e-mail it to someone. How can I 开发者_StackOverflowdo that without using a temporary file? If it's not possible, how can I do it using a temporary file?
Thanks!
Create a text file in PHP: http://www.tizag.com/phpT/filecreate.php
RSA encryption in PHP: http://stevish.com/rsa-encryption-in-pure-php
Write to text file in PHP: http://www.tizag.com/phpT/filewrite.php
File Icons: The icon your file has, to the best of my knowledge, will be determined by the system/recipient reading the file and their system settings- you cant manually set in PHP, though I bow to the wider knowledge of the SO community on this one
--if you've already created the text file, why not attach it?
Emailing via PHP Mailer: http://phpmailer.worxware.com/
Sending attachments with PHP Mailer: http://zainal.wordpress.com/2007/01/10/sending-email-attachments-in-php-using-phpmailer-class/
If the recipient is going to be using a non-standard non-PKCS#1 compliant RSA implementation use the stevish.com implementation. If you want interoperability with OpenSSL, .NET, etc, use phpseclib's pure PHP RSA implementation. It uses the gmp extension (if it's available) to achieve much faster speeds than the stevish.com implementation does but even if neither it or the bcmath extension are available it'll still work because it has its own pure PHP bignum implementation. It also uses RSA blinding to ensure that timing attacks can't be conducted.
The biggest reason to use phpseclib, though, is interoperability. Do you want the person you're sending the RSA encrypted string to to be able to decrypt it? If so, use phpseclib. If not then why are you doing RSA encryption in the first place? It's not as if they'd know whether the string you were sending was actually encrypted or not.
精彩评论