BASE64ENC

(Difference between revisions)
Jump to: navigation, search
Line 18: Line 18:
  
 
= <span class="f_Header">Remarks</span> =
 
= <span class="f_Header">Remarks</span> =
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
+
<div style="padding: 0px; margin: 0px 0px 0px 4px;"><div style="padding: 0px; margin: 0px 0px 0px 4px;">
{| width="609" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
+
{| style="border: solid 2px #000000; border-spacing:0px; border-collapse: collapse;" width="609" cellspacing="0" cellpadding="1" border="1"
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
| valign="top" width="13%" style="width: 75px; border: 1px solid rgb(0, 0, 0);" |  
+
| style="width:13%; border: solid 1px #000000;" width="13%" valign="top" |  
 
Result
 
Result
  
| valign="top" width="100%" style="width: 525px; border: 1px solid rgb(0, 0, 0);" |  
+
| style="width:100%; border: solid 1px #000000;" width="100%" valign="top" |  
A string variable that is assigned with the coded string.
+
A string variable that is assigned with the base64 coded string.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
| valign="top" width="13%" style="width: 75px; border: 1px solid rgb(0, 0, 0);" |  
+
| style="width:13%; border: solid 1px #000000;" width="13%" valign="top" |  
 
Source
 
Source
  
| valign="top" width="100%" style="width: 525px; border: 1px solid rgb(0, 0, 0);" |  
+
| style="width:100%; border: solid 1px #000000;" width="100%" valign="top" |
The source string that must be code with base-64.
+
The source string that must be coded.
 +
 
 +
|- style="vertical-align: top;"
 +
| style="width:13%; border: solid 1px #000000;" width="13%" valign="top" |
 +
array
 +
 
 +
| style="width:100%; border: solid 1px #000000;" width="100%" valign="top" |
 +
The first element of a byte array.
 +
 
 +
|- style="vertical-align: top;"
 +
| style="width:13%; border: solid 1px #000000;" width="13%" valign="top" |
 +
length
 +
 
 +
| style="width:100%; border: solid 1px #000000;" width="100%" valign="top" |  
 +
The number of elements to convert. Maximum 255.
  
 
|}
 
|}
Line 44: Line 58:
 
The provided Base64Enc() function is an encoding function. You need it when you want to send attachments with POP3 for example.
 
The provided Base64Enc() function is an encoding function. You need it when you want to send attachments with POP3 for example.
  
The target string will use 1 additional byte for every 3 bytes.
+
The target string will use 1 additional byte for every 3 bytes. This means that the target string is ca. 33 % longer than the source string.
  
 
So make sure the target string is dimensioned longer then the original string.
 
So make sure the target string is dimensioned longer then the original string.
  
 +
&nbsp;
 +
 +
Because strings can not contain a 0 byte, there is an alternative syntax. Instead of a string you pass the address of a byte array that contains the data you want to convert.
 +
 +
Because there is no end of string marker, you must provide the number of elements to convert.&nbsp;
 +
</div>
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  

Revision as of 20:03, 17 January 2017

Contents

Action

Converts a string into the Base-64 representation.

 

 

Syntax

Result = BASE64ENC( source)

Result = BASE64ENC( array, length)

 

 

Remarks

Result

A string variable that is assigned with the base64 coded string.

Source

The source string that must be coded.

array

The first element of a byte array.

length

The number of elements to convert. Maximum 255.

 

Base-64 is not an encryption protocol. It sends data in 7-bit ASCII data format. MIME, web servers, and other Internet servers and clients use Base-64 coding.

 

The provided Base64Enc() function is an encoding function. You need it when you want to send attachments with POP3 for example.

The target string will use 1 additional byte for every 3 bytes. This means that the target string is ca. 33 % longer than the source string.

So make sure the target string is dimensioned longer then the original string.

 

Because strings can not contain a 0 byte, there is an alternative syntax. Instead of a string you pass the address of a byte array that contains the data you want to convert.

Because there is no end of string marker, you must provide the number of elements to convert. 

 

 

See also

CONFIG TCPIP , GETSOCKET , SOCKETCONNECT , SOCKETSTAT , TCPWRITE , TCPWRITESTR , CLOSESOCKET , SOCKETLISTEN , BASE64DEC

 

 

Example


$regfile = "m48def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
$lib "tcpip.lbx"
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
 
Dim S As String * 15 , Z As String * 15
 
S = "bWFyazptYXJr"
Z = Base64dec(s)
Print Z 'mark:mark
s = Base64Enc(z)
Print s
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language