Archived Forum Post

Index of archived forum posts

Question:

GenEncodedSecretKey encodings

Feb 04 '13 at 04:08

Hi, I'm using CkCrypt2's genEncodedSecretKey() function to generate a const char* (or const wchar_t* in unicode) secret key. The documentation tells me the function returns:

...a string encoded according to encoding, which may be "base64", "hex", "url", etc.

What it doesn't say is what the "etc" covers - what other encodings are allowed? If I specify "ascii", for instance, it returns what looks like an ascii string, but it is not a consistent length (I'd expect 32 chars for a 256 bit key length): the length can be anything from 1 to 32 chars before a null terminator is found.

Is there a list of exactly which encodings can be used for this function? I ideally want to get back an ascii encoded string, 32 chars in length...


Accepted Answer

The list of encoding algorithms is the same as those listed for the CkCrypt2's EncodingMode property, which is "Base64", "modBase64", "Base32", "UU", "QP" (for quoted-printable), "URL" (for url-encoding), "Hex", "Q", "B", "url_oath", "url_rfc1738", "url_rfc2396", and "url_rfc3986".

In general, wherever an encoding string argument is specified, then any of these encodings can be used. If/when Chilkat adds a new encoding implementation to the API, it will automatically be available across-the-board in all API's that might have a method argument or property that specifies encoding.

PS> Don't confuse this kind of encoding with character encoding, which is a different subject. Character encodings, also known as charset's or code-pages, are things such as "utf-8", "iso-8859-1", "utf-16", "us-ascii", "ebcdic", etc.