initial commit
This commit is contained in:
commit
f0d73a3137
46
fxkr.c
Normal file
46
fxkr.c
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
get_char_int(char in)
|
||||||
|
{
|
||||||
|
char buf[2];
|
||||||
|
buf[0] = in;
|
||||||
|
buf[1] = 0;
|
||||||
|
return atoi(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
decode(char *in)
|
||||||
|
{
|
||||||
|
static char result[9];
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
if (strlen(in) != 16) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 15; i += 2, ++idx) {
|
||||||
|
int first = get_char_int(in[i]);
|
||||||
|
int second = get_char_int(in[i+1]);
|
||||||
|
result[idx] = first * 16 + second;
|
||||||
|
}
|
||||||
|
|
||||||
|
result[8] = 0;
|
||||||
|
|
||||||
|
return &result[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *input = "3041314232433344";
|
||||||
|
char *result = decode(input);
|
||||||
|
|
||||||
|
printf("keyword is: %s\n", result);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user