Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- void decrypt(uint16_t cipher[], char clear[], int ct_len){
- // Decrypt a XORed string. ciphertext is a uint16_t of
- // length n (from ct_len), and cleartext is a char of
- // length 2n + 1 (2 chars per 16bits, plus \0)
- for (int i = 0; i < ct_len; i++){
- uint16_t decpair = cipher[i] ^ 31337;
- // Take the dec'd pair, mask, shift, save
- clear[(2*i)] = (char) ((decpair & 0xF0) >> 8);
- clear[(2*i)+1] = (char) ((decpair & 0x0F) >> 0);
- }
- // Make the last char in the cleartext a nullchar.
- clear[(2*ct_len)] = '\0';
- return;
- }
- void main(){
- uint16_t ciphertext[] = {
- 15643,
- 6913,
- 6916,
- 23040,
- 2377,
- 6985,
- 6408,
- 3657,
- 5638,
- 3084,
- 2119,
- 15910,
- 23079,
- 13629,
- 23101,
- 10300,
- 10557,
- 23073,
- 13092,
- 23369
- };
- int cipherlen = 20;
- char cleartext[41];
- decrypt(ciphertext, cleartext, cipherlen);
- printf(cleartext);
- getchar();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement