Swinging My Bucket (Source Included)

BlitzMax Forums/BlitzMax Beginners Area/Swinging My Bucket (Source Included)

dw817(Posted 2016) [#1]
Final Version of my encryptor and decryptor is below !
http://www.blitzbasic.com/Community/post.php?topic=105767&post=1293912

I have and always will be fascinated by the ability of a programming language to allow the user to develop a set of random numbers based on a fixed seed number. I'm posting this in the beginner's area as it just focuses on one command that everyone should be already familiar with.

Question, can I rely on BlitzMAX's SeedRnd() for reliable and unbreakable encryption ?

Here is the code, do you get the same results I do ?

What would be a more accurate test of stability ?




grable(Posted 2016) [#2]
The short answer: HELL NO!

The random functions in blitzmax are just wrappers around the libc random functions.
Which are PRNGs, ie pseudo random. Now that property alone doesnt make them inherrently insecure.
Its that the implementation is built for speed (for the most part) making them deterministic, the worst property for security.
NEVER use them for anything security related.

What you want is a cryptographically secure random function, of which you can find plenty


dw817(Posted 2016) [#3]
Aww man ! Shoof, that means I can't use a method like this to encrypt files ?

http://www.blitzbasic.com/Community/posts.php?topic=105762

What would be good encryption for 6-bit ? I am interested in this.

... Correcting myself. I CAN create a 64-character encryption CODE, that would be solid, no need to seed random. Let me see if I can fix that code. I may be able to do something interesting and it won't use RndSeed() to decrypt.

Updating

Can you recommend some BlitzMAX code that generates the type of 'random' you are referring to ?


grable(Posted 2016) [#4]
Well you certainly can. But if anyone can suss out your seed value, going backwards through the algorithm would allow them to guess every random number in sequence.
So it would not be very secure.

Now whether you actually need it to be secure is another matter.

EDIT: I seem to remember Brucey having a BAH.Random module or something, but i could be wrong.
Other than that you would have to turn to a C/C++ library, theres plenty on github.
Though i cannot say if either Bruceys or the ones on github are really secure, cryptography isnt my field ;)

If you want REAL security, rolling your own is probably a bad idea unless you know your stuff.


dw817(Posted 2016) [#5]
Well, here is a shot in the dark I tried. I like it. You change one single character and the whole string changes. Does not use Rnd(), RndSeed(), or Rand().




Casaber(Posted 2016) [#6]
I think you want a Mersenne Twister

Here's a BASIC implementation which looks effecient which I think would be a great guide when writing one.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/BASIC/vb_mersennetwister_rev1.txt


dw817(Posted 2016) [#7]
Errm ... This isn't BlitzMAX ... Where's the key ? The text you enter to encrypt the text ?

Currency is mentioned so is this a calculator for foreign money ?

I think my encrypt up above is pretty solid. I suppose I could build some massive arrays to house more massive numbers to swirl around. Whattamess that would be.

While unbreakable encryption would be nice, the use I have for this doesn't need to be.

It's just like above. Doesn't need to be fancy. You have a normal character set, and you have an encryption set. Both are 64-characters in length.

Using the encryption set you can decrypt that which was encrypted with it, you do not need to recalculate or recompute anything.

It's your classic super decoder ring. It doesn't need to be any more serious than that.


Casaber(Posted 2016) [#8]
Is's a general VB source the only part that's interesting is the function called Mersenne, it seem to be a popular random generator for lots of things.
I would love to learn more about these myself one day.


Brucey(Posted 2016) [#9]
I think my encrypt up above is pretty solid

Heh. Seriously?

Perhaps we can use it to replace SHA-1 :-)


xlsior(Posted 2016) [#10]
Obfuscation: A process applied to information to intentionally make it difficult to reverse without knowing the algorithm that was applied.

Encryption: A process applied to information that, even knowing the algorithm applied, requires a secret (key) to reverse it in a reasonable amount of time.


Derron(Posted 2016) [#11]
@mersenne twister
This is a pseudo random number generator which does always return the same numbers with a given constant seed.

so with seed X you always get 10 as first number, 12 as second ...

This is useful for Multiplayer as you just start with the same seed and all random numbers they use (of course only if they do the same amount of "requests") are the same.

Implementation (copied from somewhere here on the forums)
https://github.com/GWRon/Dig/blob/master/base.util.mersenne.bmx
https://github.com/GWRon/Dig/blob/master/base.util.mersenne.c


But like said: encryption <> random number encoding

bye
Ron


dw817(Posted 2016) [#12]
Brucey, care to decrypt a sentence I use to encode it with ? ^.^

If you or anyone else on the board can break the code, that's good enough for me.
You even have the ADDED advantage of using my program below, little good it might do you. :D



arBGwZuu9pVkWok.IRrSdSI2w5N1de8bKcdfKNMD4Kqj2hEi7UU24qPqBGhvynEA0WCZlVy19vvYzQSQxfnIg99w
You're up !

. . .

Ron, yes, no I'm very comfortable with Blitzmax's own Random function, this is all about encryption.

Xslior, this is Encryption as you have your hands on the source. Merely guess the right key word or sentence and the encrypted text will reveal itself.


dw817(Posted 2016) [#13]
Oh, and here is the code I plan to use for final. This one is Brucey's copy. Brucey - I MAY have changed a number in this just to keep things interesting. You said it was an easy encryptor right ? You may not even need this code. :)

You are welcome to use any resources on the Internet to help you. If you =DO= solve the encryption though, you are politely requested however to state how you did it and with what tools.

This will be an interesting challenge and experiment.