r/shittyprogramming • • Jul 09 '14

generating a 512-bit int

Post image
277 Upvotes

46 comments sorted by

38

u/ich_bin_Sal Jul 09 '14

I want to know the train of thought of OP to come to the conclusion "hmm, I need to generate a FIVE HUNDRED AND TWELVE bit integer"

11

u/weirdasianfaces Jul 09 '14

From OP:

Thank you :), and yeah I thought about using an array, but Im trying to implant RSA (for learning purposes) and that would make the keys easy to crack. Before posting on reddit I found this link[1] which is what I was trying to do an then I kept getting the error, so I asked reddit :)

5

u/pyfrag Jul 12 '14

Good to know that these kind of people are trying to write secure code.

14

u/push_ecx_0x00 Jul 20 '14

HE'S IMPLANTING RSA

71

u/katyne Jul 09 '14

he's making a weight loss tracker for his mom. BADUM TSH!

15

u/ekolis Jul 09 '14

Cryptography maybe? Or scientific simulations?

Though if someone this clueless is supposed to be implementing either of those things, then that's the real WTF...

3

u/[deleted] Jul 09 '14

I did too at first, but then I realized I have to deal with other peoples shitty solutions every day.

1

u/[deleted] Jul 10 '14

my calculator supports arbitrary length integers... not sure why a computer shouldn't be able to handle a 64-byte long hex string

13

u/dhvl2712 Jul 09 '14

Hang the fuck on. There's no way in hell, he just wrote the literal string '512 bit int' and expected it to work. He might've meant it as a placeholder or something.

5

u/weirdasianfaces Jul 09 '14

OP comes from a Python background it looks like. I thought the same but in no way did he indicate that was a placeholder though.

16

u/Creshal Jul 09 '14

Not even Python excuses this.

0

u/spidyfan21 Jul 19 '14

I'm not sure how anything in Python would excuse this.

0

u/[deleted] Jul 12 '14

[deleted]

2

u/glitchn Jul 12 '14

Sure its possible, but theres not much need for it and there are often better ways to store and work with such large numbers.

10

u/hatsune_aru Jul 09 '14

Was that a troll question?

32

u/weirdasianfaces Jul 09 '14

Nope. OP seemed pretty happy to find out about the BigInteger struct.

31

u/hatsune_aru Jul 09 '14

god help us all

16

u/YesSoupForYou Jul 09 '14

new microsoft SDE in training

77

u/SuperFLEB Jul 09 '14

"What am I doing wrong?"

All of it, actually.

15

u/GrantSolar Jul 09 '14

It's quite spectacular how every bit of it is terrible. Even the variable name 'startPrime'. "Yeah, I'll just generate a random number and it'll be prime, since there's infinitely many it's a dead cert!"

1

u/delingren Sep 07 '24

I’m pretty sure it’s going to be a prime. Prove me wrong. 

49

u/ekolis Jul 09 '14

No, silly! That's not how you do it! A regular int is 32 bits, so what you need to do is ToString() eight regular ints, then concatenate them all, then Int.Parse() the result.

16

u/Famous1107 Jul 09 '14

store that as, ReallyBigInt urbi = ReallyBigInt.Parse("99999999999999999999999...");

The u denotes an unsigned ReallyBigInt, also known as a big ass int.

105

u/northrupthebandgeek Jul 09 '14

It looks like his issue is that he's using C#. He should try using a real programming language, like Visual Basic.

38

u/[deleted] Jul 09 '14

Haha visual basic. You kids. Why don't you use a battle tested, tried and true language like QBasic?

You and your 6.0 this and your dot net that. Its all a flash in the pan, mark my words. In six months, no one will be blogging about VB anymore.

17

u/shillbert Jul 09 '14

QBasic isn't enterprise scale. I use QuickBasic to run my business.

20

u/[deleted] Jul 09 '14

disruptive startup

FTFY

4

u/gullinbursti Jul 09 '14

RND Master race!

0

u/[deleted] Jul 09 '14

QBasic - oh my god. I did that a little bit in 6th grade.

10

u/XL_ARES_IX Jul 09 '14

Or Java. In fact, I made some code to help him out

int my512Integer = Integer.getInteger("512"); //this generates a new 512 bit integer
Random random = new Random(my512Integer);
int newRandom = random.nextInt();

29

u/tusksrus Jul 09 '14

java.util.Integer512BitInteger myInteger512BitInteger = java.util.Integer512BitInteger.createInteger512BitInteger(new java.util.Integer512BitIntegerFactory(), java.lang.Integer.getInteger("512"));

8

u/ajs124 Jul 09 '14

please tell me this isn't real, please tell me this isn't real.

16

u/tusksrus Jul 09 '14

It's a planned feature for Java 9 (officially called Java 8.1).

8

u/ekolis Jul 09 '14

The sad thing is, I would not be surprised if you're completely serious...

6

u/Randolpho Jul 09 '14

That one made me lol, then cry.

3

u/peridox Jul 09 '14

...but mostly cry.

6

u/Barricaded_EDP Jul 09 '14

Needs more factories

1

u/Rockytriton Jul 24 '14

The factory should return a builder which creates the integer

2

u/Rockytriton Jul 24 '14

only if it's VB 3.0 16-bit, that's what the real hackers use

23

u/RunasSudo Jul 09 '14

Next week:

boolean value = "file not found"
What am I doing wrong???

25

u/haitei Jul 09 '14

You forgot a semicolon, obviously.

7

u/davidwhitney Jul 09 '14

I resisted the urge to post this here, but as far as WTFs/Minute go, this is a new classic.

5

u/[deleted] Jul 09 '14

Language is fine, but since bit isn't defined, 512-bit gives an error.

2

u/FalconGames109 Jul 09 '14

The problem is probably the dash. It is being detected as the minus sign, so the method expects a negative number or something but nothing comes after.

-11

u/jen1980 Jul 09 '14

Sigh, Microsoft programmers.

7

u/Appathy Jul 09 '14

Yeah, you know nothing Jon Skeet!

-3

u/[deleted] Jul 09 '14

Yes, let's all make fun of newbies!