Would really love some help on getting this working.
I was given the decrypt function and was trying to build the shell. I really don't remember my pointers and references, but think it is close...
Please help! - Thanks!
Code:
#include <stdio.h>
void decrypt();
int main() {
char in[255] = "NpfTvZKQKlM8Jh19/vI";
decrypt(in);
}
int index(char *x) {
char encIndex[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
// Not sure how to reference the array, but I believe I need to take in a char and return
// an int.
return 0;
}
void decrypt (char *in)
{
char first, second, third, fourth;
int lf_count = 0,
i = 0;
int byte_count = strlen(in);
while (byte_count > 0)
{
first = index(&in[i]);
second = index(&in[i + 1]);
third = index(&in[i + 2]);
fourth = index(&in[i + 3]);
if (byte_count > 2)
first = (first << 2) | (second >> 4);
else
first = (first << 2);
printf("%c", first);
if (byte_count > 2)
{
if (byte_count > 3)
second = (second << 4) | (third >> 2);
else
second = (second << 4);
}
printf("%c", second);
if (byte_count > 3)
{
third = (third << 6) | fourth;
printf("%c", third);
}
i += 4;
byte_count -= 4;
lf_count++;
}
}