Converting Data Between Binary and ASCII
172 RSA BSAFE Crypto-C Developers Guide
Converting Data Between Binary and ASCII
If you have data in binary format, yet need it in ASCII, or vice versa, Crypto-C offers
functions to encode and decode according to the RFC1113 standard.
The example in this section corresponds to the file encdec.c.

Encoding Binary Data To ASCII

Step 1: Creating An Algorithm Object
Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in
Chapter 4 of the Reference Manual, its address is the argument for
B_CreateAlgorithmObject:
Step 2: Setting The Algorithm Object
There is only one ASCII encoding or decoding AI, AI_RFC1113Recode. The Reference
Manual Chapter 2 entry for this AI states that the format of
info
supplied to
B_SetAlgorithmInfo is NULL_PTR:
Step 3: Init
To initialize ASCII encoding, call B_EncodeInit. This function takes only one
argument, the algorithm object:
B_ALGORITHM_OBJ asciiEncoder = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&asciiEncoder)) != 0)
break;
if ((status = B_SetAlgorithmInfo
(asciiEncoder, AI_RFC1113Recode, NULL_PTR)) != 0)
break;