Buffer data is converted to string output

Source: Internet
Author: User

Recently, I helped my friends use Delphi to perform an AES encryption and decryption process.ProgramTo display the buffered data during the process. The first consideration is to convert the byte array to a string, and no suitable method is found for searching the network. Later, when viewing the tstream class, there is a tstringstream that can directly read data from the buffer and then convert it to a string.

CodeAs follows:

VaR
Tempin, tempout: taesbuffer;
Strstream: tstringstream;
S: string;
Begin
// Create a strstream object
Strstream: = tstringstream. Create (s );
Try
// Restore the pointer to the string Header
Strstream. Seek (0, sofrombeginning );
// Read data from the buffer
Strstream. Write (tempout, sizeof (tempout ));
Finally
Strstream. Free;
End;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.