note that using base64 or uuencode to store data in a database is pretty useless. if you properly escape your data and use a binary field (BLOB etc) there is no problem.
convert_uuencode
(PHP 5)
convert_uuencode — Encode une chaîne de caractères en utilisant l'algorithme uuencode
Description
string convert_uuencode
( string $data
)
convert_uuencode()encode une chaîne de caractères en utilisant l'algorithme uuencode.
Uuencode traduit toutes les chaînes (y compris les binaires) en caractères imprimables, pour assurer leur transmission sur Internet. Les données au format uuencode sont environ 35 % plus grandes que les originales.
Liste de paramètres
- data
-
Les données à encoder.
Valeurs de retour
Retourne les données, au format uuencode.
Exemples
Exemple #1 Exemple avec convert_uuencode()
<?php
$some_string = "test\ntext text\r\n";
echo convert_uuencode($some_string);
?>
convert_uuencode
zash at zash dot se
30-May-2008 09:30
30-May-2008 09:30
Vipindas K.S
08-May-2008 06:42
08-May-2008 06:42
Code snippet for Encoding passwords using convert_uuencode and store in mysql database .
Consider a file named "test.php" consisting of an input form as given below:
<html>
<body>
<form action="test.php" method="post">
<input type="text" name="fname" id="fname" />
<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="submit" />
</form>
<?
/*
below php code takes input field values , encode the password and then store the values in a database .
Create a table named test with fields id,name,password where id is auto incremented..
*/
if(isset($_post['submit']))
{
$fname=$_POST['fname'];
$pass=$_POST['password'];
$encoded_pass=convert_uuencode($pass);
$con=mysql_connect("your hostname","your username","your password"); //connecting to the database
$db=mysql_select_db("your_database_name",$con);
$sql="INSERT INTO test (id,name,password) VALUES('','$fname', '$encoded_pass' )";
$result=mysql_query($sql)or die("unable to insert");
}
?>
</body>
</html>
allali at labri dot fr
02-Apr-2008 10:06
02-Apr-2008 10:06
if you want to use convert_uuencode with command uudecode you must insert a line "begin %s %s\n" at the beginning and "end\n" at the end:
<?php
echo "begin 644 hello.txt\n";
echo convert_uuencode("hello");
echo "end\n";
?>
the first arg. after begin is the mode (destination file rights), the second is the destination file name.
Then you can do a wget followed by a uudecode.
JA.
root at mantoru dot de
10-Nov-2007 06:29
10-Nov-2007 06:29
@Craig's note: base64_encode() is better suited for that. In fact, it produces smaller output and operates slightly faster. I did a little benchmark -- here are my findings:
File: JPG, 631614 bytes
== Base64 ==
execution time: 0.0039639472961426 secs
output length: 842152
== UUencode ==
execution time: 0.004105806350708 secs
output length: 870226
tmaschler at NOSPAM dot ditf-denkendorf dot de
20-Sep-2006 10:46
20-Sep-2006 10:46
Note to the tip of Craig at frostycoolslug dot com:
If you are using fulltext functionality on columns with uuencoded texts, collations will not work. You might prefer to pass the text escaped to the database engine.
nmmm at nmmm dot nu
12-Apr-2006 05:17
12-Apr-2006 05:17
uuencode is recognisable as email attachment in Ms Outlook, but in Outlook Express (at least in older versions) - is not.
This is shell script, but it may give you an idea how you can send attachments using uuencode:
cat file.bin | uuencode file.bin | mail someone@domain.com -s "file.bin"
uuencode mail attachments from other point of wiev are deprecated. However I use such technic for years now and it work well.
aidan at php dot net
29-May-2005 05:51
29-May-2005 05:51
This functionality is now implemented in the PEAR package PHP_Compat.
More information about using this function without upgrading your version of PHP can be found on the below link:
http://pear.php.net/package/PHP_Compat
Craig at frostycoolslug dot com
09-Aug-2004 04:15
09-Aug-2004 04:15
This function can be useful if you wish to store files in a MySQL database, it will save any problems with obscure binary data breaking the queries.
just remember to convery-uudecode before you try to use the data again.
(A common example of something that uses this system, would be email attachments)
