1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 import core
.stdc
.stdlib
: malloc
, free
;
25 import core
.stdc
.string
: strlen
, strcpy
;
26 import core
.stdc
.stdio
: stderr
, printf
, fprintf
;
28 gcry_cipher_hd_t handle
;
29 gcry_cipher_hd_t handle2
;
35 plain_text
= cast(char*)malloc(1024);
36 strcpy(plain_text
, "Attack at dawn");
38 outbuf
= cast(char*)malloc(strlen(plain_text
)+1);
39 deout
= cast(char*)malloc(strlen(plain_text
)+1);
41 gcry_check_version(null);
42 gcry_control(GCRYCTL_DISABLE_SECMEM_WARN
);
43 gcry_control(GCRYCTL_INIT_SECMEM
, 16384, 0);
45 err
= gcry_cipher_open(&handle2
, GCRY_CIPHER_ARCFOUR
, GCRY_CIPHER_MODE_STREAM
, 0);
46 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
48 err
= gcry_cipher_open(&handle
, GCRY_CIPHER_ARCFOUR
, GCRY_CIPHER_MODE_STREAM
, 0);
49 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
51 err
= gcry_cipher_setkey(handle
, KEY
.ptr
, KEY
.length
);
52 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
54 err
= gcry_cipher_setkey(handle2
, KEY
.ptr
, KEY
.length
);
55 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
57 err
= gcry_cipher_encrypt(handle
, cast(ubyte*)outbuf
, strlen(plain_text
)+1, cast(const(ubyte)*)plain_text
, strlen(plain_text
)+1);
58 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
60 for (int idx
= 0; idx
< strlen(plain_text
); ++idx
) {
61 uint ch
= outbuf
[idx
];
65 // 45A01F645FC35B383552544B9BF5
66 // 45A01F645FC35B383552544B9BF5
68 err
= gcry_cipher_encrypt(handle2
, cast(ubyte*)deout
, strlen(plain_text
)+1, cast(const(ubyte)*)outbuf
, strlen(plain_text
)+1);
69 if (err
) fprintf(stderr
, "Failure: %s/%s\n", gcry_strsource(err
), gcry_strerror(err
));
70 printf("%s|\n", deout
);
76 gcry_cipher_close(handle
);
77 gcry_cipher_close(handle2
);