this post was submitted on 07 Sep 2024
220 points (97.8% liked)

Programmer Humor

19652 readers
2777 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 66 points 2 months ago (6 children)

If anyone wants to actually run this, here ya go:

          #include              <stdio.h>
      short i=0;long          b[]={1712,6400
    ,3668,14961,00116,      13172,10368,41600,
  12764,9443,112,12544,15092,11219,116,8576,8832
,12764,9461,99,10823,17,15092,11219,99,6103,14915,
69,1721,10190,12771,10065,16462,13172,10368,11776,
14545,10460,10063,99,12544,14434,16401,16000,8654,
12764,13680,10848,9204,113,10441,14306,9344,12404,
  32869,42996,12288,141129,12672,11234,87,10086,
    12655,99,22487,14434,79,10083,12750,10368,
      10086,14929,79,10868,14464,12357};long
        n=9147811012615426336;long main(){
          if(i<0230)printf("%c",(char)((
            0100&b[i++>>1]>>(i--&0x1)*
              007)+((n>>(b[i>>001]>>
                7*(0b1&01-i++)))&1
                  *main(111))));
                    return 69-
                      0b0110
                        ;}

Bonus points if you can deobfuscate it!

[–] Redkey 8 points 2 months ago* (last edited 2 months ago) (4 children)

I don't know if this will work or even compile, but I feel like I'm pretty close.

long main () {
    char output;
    unsigned char shift;
    long temp;
    
    if (i < 152) {
        shift = (i & 1) * 7;
        temp = b[i >> 1] >> shift;
        i++;
        output = (char)(64 & temp);
        output += (char)((n >> (temp & 63)) & main());
        printf("%c", output);
    }

    return 63;
}
[–] [email protected] 1 points 2 months ago (1 children)

Some kind of Caesar cipher you made?

fIy uo rolevl teet rsi'n tigev nnit ehf ro mfoh gilh yboufcstadeC ,sii terlayla l vo eelttre ? Iod'n tnkwo ,ub thwtaI d onkwoi shttaI l vo eoy!u< 3%

[–] Redkey 3 points 2 months ago* (last edited 2 months ago)

Whoops! When I looked at the second time that the shift value is calculated, I wondered if it would be inverted from the first time, but for some reason I decided that it wouldn't be. But looking at it again it's clear now that (1 - i) = (-i + 1) = ((~i + 1) + 1), making bit 0 the inverse. Then I wondered why there wasn't more corruption and realized that the author's compiler must perform postfix increments and decrements immediately after the variable is used, so the initial shift is also inverted. That's why the character pairs are flipped, but they still decode correctly otherwise. I hope this version works better:

long main () {
    char output;
    unsigned char shift;
    long temp;
    
    if (i < 152) {
        shift = (~i & 1) * 7;
        temp = b[i >> 1] >> shift;
        i++;
        output = (char)(64 & temp);
        output += (char)((n >> (temp & 63)) & main());
        printf("%c", output);
    }

    return 63;
}

EDIT: I just got a chance to compile it and it does work.

load more comments (2 replies)
load more comments (3 replies)