powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / Как сконвертить строку в base64
3 сообщений из 3, страница 1 из 1
Как сконвертить строку в base64
    #33756311
Фотография Serega128
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Как сконвертить строку в base64 на ВСВ6, но желательно без использования заумных бибилиотек? Приведите код, плиз! :)

Заранее спасибо!
...
Рейтинг: 0 / 0
Как сконвертить строку в base64
    #33757314
Карабас Барабас
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Serega128Как сконвертить строку в base64 на ВСВ6Поиск рулит.

Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
Как сконвертить строку в base64
    #33758909
Lepsik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
только инлан функции

Samples
Case 1: You want to decode a Base64-encoded application with the file name "test.b64" and store the decoded application in "test.exe".

Код: plaintext
1.
CBase64 B64;
B64.DecodeFile ("test.b64", "test.exe");
Case 2: You want to decode a Base64-encoded buffer and store the decoded data in another buffer. This case is a bit more complicated. Base64-encoded data is around 30% larger in size than normal data. This means you do not need a buffer that is as large as the buffer containing the Base64 data. This is solved for you with the CreateMatchingDecodingBuffer function. The first Parameter of this function is the address of the buffer that holds the data that you want to decode. The second parameter is an address to a char* that will receive the adress of a matching decoding buffer. DO NOT FORGET to delete this buffer as soon as you do not need it any more. Here, pInput is the buffer that contains the Base64 data.

Код: plaintext
1.
2.
3.
4.
char* pDecodedDataBuffer;
B64.CreateMatchingDecodingBuffer (pInput, &pDecodedDataBuffer);
B64.DecodeBuffer (pInput, pDecodedDataBuffer);
//...use the decoded data write it to a file etc. ...
delete pDecodedDataBuffer;

Case 3: You want to encode a file into Base64 and store the decoded data in the file in "test.b64".

Код: plaintext
1.
CBase64 B64;
B64.EncodeFile ("test.exe", "test.b64");

Case 4: You want to encode a buffer and store the encoded data in another buffer. This case is a bit more complicated than just encoding a file. Encoding a buffer means that your encoded data will be around 30% larger than your source data. To create a buffer that is capable of holding all the encoded data, you can call CreateMatchingEncodingBuffer. The function takes two parameters. The first parameter tells the function how many bytes there are in your buffer that need to be encoded. The second parameter is is the address to a char* that will be filled by the function with the address of a matching buffer for the encoded data. DO NOT FORGET to delete pInput as soon as you do not need it any more. In this sample, pInput contains 114 bytes that I want to be encoded. At first, I create a matching buffer by calling CreateMatchingEncodingBuffer. Then, I pass pInput and pB64Output to EncodeBuffer and tell it that there are 114 bytes to encode in pInput. The function now converts the bytes from pInput to Base64 and stores the result in pB64Output.

Код: plaintext
1.
2.
3.
4.
char* pB64Output;
B64.CreateMatchingEncodingBuffer (pInput, &pB64Output);
B64.EncodeBuffer (pInput,  114 , pB64Output);
//... process the encoded data write it to a file, etc.
delete pInput;
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / C++ [игнор отключен] [закрыт для гостей] / Как сконвертить строку в base64
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]