Home
Software Programming Learning
EDA & IP & IC
Goodies
News
Contact Us
Article
Contents Of Article
Previous Article
SNO:
Writer:
Next Article
Title:
<?php $flag=0; if (!empty($_FILES['uploadfile']['name'][0]) && !empty($_FILES['uploadfile']['name'][1])){ $flag = 1; if ($_FILES['uploadfile']['size'][0] = 0 || $_FILES['uploadfile']['size'][1] = 0) { echo 'Error: Either File or Codebook is not defined!<br/>'; } else { move_uploaded_file($_FILES['uploadfile']['tmp_name'][0],'tmp/tmp0'); move_uploaded_file($_FILES['uploadfile']['tmp_name'][1],'tmp/tmp1'); $s1 = file_get_contents('tmp/tmp0'); $s2 = file_get_contents('tmp/tmp1'); $limiti = strlen($s1); $limitj = strlen($s2); $j = 0; for ($i=0;$i<$limiti;$i++){ $s1[$i] = $s1[$i] ^ $s2[$j]; if (++$j == $limitj) $j = 0; } file_put_contents('tmp/tmp3',$s1); } } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Server-based XOR File Encoder/Decoder</title> <style> div, article, section, footer, nav { text-align:center; font-family:Calibri; font-weight:bold; font-size:20px; color:#0070C0; } textarea, input { font-family:Calibri; font-size:18px } </style> </head> <body style="background-color:rgb(221,221,221)"> <header> <div style="height:100px"> <a href="index.html"><img src="ATL_logo.png" width="480"/></a> </div> <br/> <!div style="background-color:#ffff00;height:40px;line-height:40px"> <!div style="background-color:#00aff0"> <div style="background-color:rgb(255,204,0);height:40px;line-height:40px"> <a href="index.html">Home</a> <a href="sw_pro.html">Software Programming Learning</a> <a href="eda_ip.html">EDA & IP</a> <a href="goodies.html">Goodies</a> <a href="news.html">News</a> <a href="mailto:info@AdvTechLink.com">Contact Us</a> <a href="article.php">Article</a> </div> </header> <div> <h3>XOR-based File Encoder/Decoder(Server-version)</h3> <form method="post" enctype="multipart/form-data" action="filecodec.php"> File: <input type="file" id="file1" name="uploadfile[]"/> Codebook: <input type="file" id="file2" name="uploadfile[]"/><br/><br/> <output id="list">Message Block</output><br/><br/> <script> function handleFileSelect(evt) { document.getElementById('list').innerHTML = "File size is "+evt.target.files[0].size+" bytes"; if (evt.target.files[0].size > 5242880) { document.getElementById('list').innerHTML = "Error: File size is too big, "+evt.target.files[0].size+" bytes over 5M bytes."; document.getElementById('submitonoff').innerHTML = ""; } else { document.getElementById('submitonoff').innerHTML = '<input type="submit" value="Encode/Decode"/>'; } } document.getElementById('file1').addEventListener('change', handleFileSelect, false); document.getElementById('file2').addEventListener('change', handleFileSelect, false); </script> <span id="submitonoff"><input type="submit" value="Encode/Decode"/></span> <?php if ($flag == 0){ echo '<script>document.getElementById("list").innerHTML = "Please Provide both File and Codebook.";</script>'; } ?> </form> <br/> <?php if ($flag == 1) { echo '<a href="download.php?file=tmp3" target="_blank">Download tmp3<a>'; } ?> </div><br/> <footer style="background-color:rgb(0,153,0)"> <div style="font-size:18px;color:white;height:100px;line-height:25px"> <br/>Copyright @ 2014 AdvTechLink<br/> (Updated on Sep. 20, 2014 since Sep. 19, 2014)<br/> </div> </footer> </body> </html>
Previous Article
Next Article