MCPcopy Create free account
hub / github.com/MapServer/MapServer / main

Function main

msencrypt.c:39–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39int main(int argc, char *argv[])
40{
41
42 if (argc == 3 && strcmp(argv[1], "-keygen")==0)
43 {
44
45/* TODO: Move this to a function */
46 unsigned char pabyKey[16];
47 char szKeyEncoded[50];
48 FILE *fp;
49 msGenerateEncryptionKey(pabyKey);
50 msHexEncode(pabyKey, szKeyEncoded, 16);
51
52 if ((fp = fopen(argv[2], "wt")) != NULL)
53 {
54 fprintf(fp, "%s\n", szKeyEncoded);
55 fclose(fp);
56 }
57 else
58 {
59 printf("ERROR: Failed writing to %s\n", argv[2]);
60 return -1;
61 }
62 }
63 else if (argc == 4 && strcmp(argv[1], "-key")==0)
64 {
65 unsigned char key[16];
66 char *pszBuf;
67
68 if (msReadEncryptionKeyFromFile(argv[2], key) != MS_SUCCESS)
69 {
70 printf("ERROR: Failed reading key from file %s\n", argv[2]);
71 return -1;
72 }
73
74 pszBuf = (char*)malloc((strlen(argv[3])*2+17)*sizeof(char));
75 MS_CHECK_ALLOC(pszBuf, (strlen(argv[3])*2+17)*sizeof(char), -1);
76
77 msEncryptStringWithKey(key, argv[3], pszBuf);
78
79 printf("%s\n", pszBuf);
80 msFree(pszBuf);
81 }
82 else
83 {
84 PrintUsage();
85 }
86
87 return 0;
88}

Callers

nothing calls this directly

Calls 6

msGenerateEncryptionKeyFunction · 0.85
msHexEncodeFunction · 0.85
msEncryptStringWithKeyFunction · 0.85
msFreeFunction · 0.85
PrintUsageFunction · 0.85

Tested by

no test coverage detected