xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_Base64Encode()

Encodes a character string base 64.

Syntax

HB_Base64Encode( <cString>, <nBytes> ) --> cBase64

Arguments

<cString>
This is a character string to encode with the base 64 algorithm.
<nBytes>
The number of bytes to encode from <cString> must be passed as second parameter. Use the expression Len(<cString>) to encode the entire string.

Return

The function returns a base 64 encoded character string.

Description

HB_Base64Encode() uses the Base 64 algorithm for encoding a character string. The encoded string is about one third larger than the original string, but contains only alphanumeric characters.

Pass the resulting string to function HB_Base64Decode() to obtain the original data.

Info

See also:HB_Base64Decode(), HB_Base64DecodeFile(), HB_Base64EncodeFile()
Category: Encoding/Decoding , xHarbour extensions
Source:tip\encoding\Base64.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example outlines base 64 encoding and decoding.

   PROCEDURE Main
      LOCAL cString := "xHarbour"
      LOCAL cBase64 := HB_Base64Encode( cString, Len(cString ) )

      ? cBase64                     // result: eEhhcmJvdXI==
      ? HB_Base64Decode( cBase64 )  // result: xHarbour

   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe