I have a couple of routines that I use to encrypt/decrypt passwords for many of the programs that I write. It is very simple and, at best, will only keep the honest people honest. You're welcome to it, if it will help:
// encrypt a password from text to add-index
char *EncryptPassword(char *inPasswd)
{
static char pwBuffer[64];
int w, x;
// init
memset(pwBuffer, 0, sizeof(pwBuffer));
x = strlen(inPasswd);
if (x > 0)
{ // loop through the string, adding the index
for (w = 0; w < x; w++)
pwBuffer[w] = (char)(inPasswd[w] + (w + 1));
}
return(pwBuffer);
}
//---------------------------------------------------------------------------
// decrypt a password from text that was add-index encrypted
char *DecryptPassword(char *inPasswd)
{
static char pwBuffer[64];
int w, x;
// init
memset(pwBuffer, 0, sizeof(pwBuffer));
x = strlen(inPasswd);
if (x > 0)
{ // loop through the string, subtracting the index
for (w = 0; w < x; w++)
pwBuffer[w] = (char)(inPasswd[w] - (w + 1));
}
return(pwBuffer);
}
//---------------------------------------------------------------------------