开发者

fwrite , fputs byte safe

I want to send data via POST to a php page, I need to store the bytes exactly as they are but I wasn't able to do it. When I send 138 bytes, fputs and fwrite returns 133.

$fh = fopen($myFile, 'ab') or die("can't open file");
echo fputs($fh, $_POST['data'] ,strlen($_POST['data']));
fclosw

VB.NET:

Dim ar As System.Text.UTF8Encoding = New System.Text.UTF8Encoding
Request.ContentLength = ar.GetByteCount(PostData)
ContentType = "application/x-www-form-urlencoded"
SW = New StreamWriter(Request.GetRequestStream(), ar)
SW.Write(PostData)

-edit this is开发者_开发问答 the encrypted data function

Public Function Encrypt(ByVal stringToEncrypt As String, ByVal key As String) As String
    Rijndael.Key = SHA256.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key))
    Rijndael.Mode = CipherMode.ECB
    Dim Buffer As Byte() = ASCIIEncoding.UTF8.GetBytes(stringToEncrypt)
    Return Convert.ToBase64String(Rijndael.CreateEncryptor().TransformFinalBlock(Buffer, 0,  Buffer.Length))
    End Function

EDITED example, original encrypted string:

j/aokbSUDP1nAD7KafnDoLSmI93sOLiroTwcQIUS/Xw8eUlUZA58OULXCtsnkKqOe+UXlFP6vKuTIWxVMRBZLiBiIOZomNsvoIfM4dv2UzAk2q5mpjo4/0E9lPvu4I7X

after sending

j/aokbSUDP1nAD7KafnDoLSmI93sOLiroTwcQIUS/Xw8eUlUZA58OULXCtsnkKqOe UXlFP6vKuTIWxVMRBZLiBiIOZomNsvoIfM4dv2UzAk2q5mpjo4/0E9lPvu4I7X


I don't see a reason why this wouldn't work:

$connection = fopen($file, 'ab');
fwrite($connection, urldecode($_POST['data']));
fclose($connection);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜