I'm trying to understand how the function encrypt works (linux), but event with this simple example is not working.
Any ideas?. Thank you.

#define _XOPEN_SOURCE

#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <string>

int main()
{
    const char key[64] = "12" ;      /* bit pattern for key */
    char txt[64] = "test encrypt";      /* bit pattern for messages */

    // set Key
    setkey(key);

    // show original
    std::cout << "Original text : " << txt << std::endl;

    // encode
    encrypt(txt, 0);
    std::cout << "Encrypted : " << txt << std::endl;

    // decode
    encrypt(txt, 1);
    std::cout << "UnEncrypted : " << txt << std::endl;

    return 0;
}

According to the help file:

The block argument to encrypt() is an array of length 64 bytes containing only the bytes with numerical value of 0 and 1

ok, thank you good advise to review the api.

If your question is answered, please remember to mark this solved. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.