Hey Sup Forums, I'm a beginner in C and I made a one-time pad encryption program and I wanna see if you can break it

Hey Sup Forums, I'm a beginner in C and I made a one-time pad encryption program and I wanna see if you can break it

LWe..N1..j3laIg?zU*QK.s!B05BbV4r?0F5n~}=y#@

I'll also post the source code, tell me if you see any problems, besides the fact it generates pseudo-random numbers

#include
#include
#include

main()
{
srand((unsigned) time(NULL));
char bstr[256];
printf("Message to XOR encrypt: ");
fgets(bstr, 256, stdin);
int i;
int key[sizeof(bstr)];
for(i = 0; i < strlen(bstr); i++)
{
key[i] = (rand() % 100);
bstr[i] = bstr[i] ^ key[i];
if(!isprint(bstr[i])) {bstr[i] = '.';}
}
printf("\n%s\n",bstr);
}

>One time pad
>Breaking
Jimbob! Get the pipe wrench!

Yeah, I guess that was pretty retarded of me

What's the point of encrypting something when you can't decrypt it afterwards

It is more fun than just generating random numbers

>I'm a beginner in C

Why the fuck are you using C over C++ for anything that doesn't involve ABIs?

>yfw C ABI was never defined

The C standard doesn't define an ABI because it's far too system-specific to be standardised, but they do go adding features that force implementations to break theirs.

OMFG THAT'S A REVERSE ONE TIME PAD ENCRYPTION YOU MORON.

It really doesn't matter when you're starting out seeing as c is a subset of c++ genius

i just suffered a seizure because of that gif

B..]Y`F.yBPI{FT

Hey..g/..can you even.break this, faggots?.

Whoops haha

Are you on windows?

EQ{x/aSH.=i{O?gs=Fty.

>HEY GUYS, GONNA INPUT COMPLETELY RANDOM LETTERS AND USE A KEY OF RANDOM DIGITS FOR YOU TO GUESS
fucking idiots. You need a pattern to crack things. Theres literally no way of confirming what you think is the key.
Things like this arent cracked, they are brute forced or the key is stolen from the servers. In this case you dont store the key so when the program terminates literally no one will be able to know what the key is. AKA useless encryption.

As a matter of fact, I am.

>if(!isprint(bstr[i])) {bstr[i] = '.';}
Shit way of doing this. You're ensuring that the encrypted string will get corrupted upon decryption.

Everyone's already said, don't forget to solve the key distribution problem, which is the hardest part of one-time pad encryption.

> for (i = 0; i < strlen(bstr); i++)
I thought this would cause buffer overflow if the input string is more than 255 bytes, but fgets inserts a null byte at the end of the buffer, so you're good.

> key[i] = (rand() % 100);
> if(!isprint(bstr[i])) {bstr[i] = '.';}
This should probably be mod 256, though o don't know of there are security problems with having the key be in a reduced range. But changing some of the ciphertext bytes after encryption is a surefire way to make sure the message won't get to your recipient intact. Either just output the bytes to stdout and let some other program deal with it, or do it I'm hex or base64.

Also, if you tell us exactly what time you ran this code, we could decipher it (except for the dots).

>Also, if you tell us exactly what time you ran this code, we could decipher it (except for the dots).

You can assume he ran it within an hour of posting it, so you use his image timestamp.
for (x = timestamp; x > timestamp - 3600; i--)

It would be pretty much impossible to decipher without the source code though.

Right, which I think someone already did:

OP used the UNIX time in seconds to seed the standard C rand.

Presuming he generated this in the last 2-3 hours, this would be about 10000 instances to check.