02/06/20 01:36
>>158
cygwin でも使ってれば、以下のをコンパイルすれば簡単かと。
# たぶんインデント崩れるけど、悪しからず。
/* trip.c
compile: cc -o trip trip.c -lcrypt
usage: trip 'aaaa' 'zzzz' | grep hoge
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern char* crypt(const char*, const char*);
int main(int argc, char* argv[])
{
int i, i0, i1, i2, i3, i4, i5, i6, i7;
char *r, b[8], e[8], sa[3], s[9];
if (argc != 3) { fprintf(stderr, "usage: trip begin end\n"); exit(1); }
for(i = 0; i < 8; i++) {
b[i] = (i < strlen(argv[1]))? argv[1][i] : 0;
e[i] = (i < strlen(argv[2]))? argv[2][i] : 0;
}
sa[2] = s[8] = 0;
for(i0 = b[0]; i0 <= e[0]; i0++)
for(i1 = b[1]; i1 <= e[1]; i1++)
for(i2 = b[2]; i2 <= e[2]; i2++)
for(i3 = b[3]; i3 <= e[3]; i3++)
for(i4 = b[4]; i4 <= e[4]; i4++)
for(i5 = b[5]; i5 <= e[5]; i5++)
for(i6 = b[6]; i6 <= e[6]; i6++)
for(i7 = b[7]; i7 <= e[7]; i7++) {
s[0] = i0; s[1] = i1; s[2] = i2; s[3] = i3;
s[4] = i4; s[5] = i5; s[6] = i6; s[7] = i7;
sa[0] = i1; sa[1] = i2;
r = crypt(s, sa);
printf("%s\t%s\n", s, r+5);
}
exit(0);
}