This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2012-04-25 19:00:46

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Scratch Cryptography

itsmomito wrote:

Hey guys, I don't know much about encryption, but I would like to try making one. Could I join in? I will upload it as soon as i'm finished

Cool.  I don't know much either, but substitutions are right within my limits.


http://i.imgur.com/BAEgGDL.png

Offline

 

#27 2012-04-25 20:35:09

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

Bobbybee: That's why I suggested this method a few posts up.

itsmomito: Feel free to build an encryption system and submit it!  smile

Ohaiderstudios: A hash could be used to keep the actual password hidden from the owner of the server. Good idea.  smile  Just hope it's secure.  tongue

Offline

 

#28 2012-04-25 21:34:27

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

Bobbybee: That's why I suggested this method a few posts up.

itsmomito: Feel free to build an encryption system and submit it!  smile

Ohaiderstudios: A hash could be used to keep the actual password hidden from the owner of the server. Good idea.  smile  Just hope it's secure.  tongue

It's not, but let's just say that my classmates aren't exactly cryptographers  tongue


Fork Clamor on GitHub!

Offline

 

#29 2012-04-25 21:41:14

XenoK
Scratcher
Registered: 2011-09-08
Posts: 1000+

Re: Scratch Cryptography

sounds like a good idea!  only about 20% of all websites use SSL to secure users' information.  (not even mine- it's too much money)


Eternity Tasks has launched into Alpha One! http://tasks.eternityincurakai.com/EI%20projects.png

Offline

 

#30 2012-04-25 23:30:51

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

Another update on what we could use for a symmetric algorithm.

If we could create a XOR operator (using only Scratch blocks), we might be able to implement Blowfish.

I just realized that we'd have to split the string into blocks.. which might take a long time to run. :/ We'll see.

We also need a protocol. How will the encryption work? Will we have some encrypted data (like only passwords and the sort) or are we just gonna encrypt everything? Remember, messages are sent like this:

sensor-update "variable" "value"
broadcast "message"

And we can't change that format. So we are stuck with specific variables or something to signify that the data is encrypted. I was thinking of something like:

broadcast "&>>[insert encrypted data"
sensor-update "&>>" "[encrypted data]"

But of course, Scratch and the Server need to exchange the key first. So, any thoughts?

Last edited by Magnie (2012-04-25 23:31:10)

Offline

 

#31 2012-04-26 00:23:11

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Scratch Cryptography

Well guys... I'm certainly not an expert in anything related to cryptography. But I researched a little and came up with something, not sure if it is even an encryption lol.

Here's the link: http://scratch.mit.edu/projects/itsmomito/2496170

How it works: This basically has two sprites which can be placed into separate projects to communicate over the web. Each sprite generates a random key containing 5 to 100 values ranging from 10-99. The two keys are combined and used to encrypt the text. Inside of the scratch project, there is a list of all the possible inputs a user can convert. If the user types in a character not inside the list, the program will not function. However, I inserted all the values I could type on my keyboard

The Encryption: I think this might be what you were calling the "shift" encryption. It just finds each string letter's position in the possible values list and shifts the letter according to the value of the encryption key. Not sure if this is so secure, probably not. But it's my first attempt  smile

Offline

 

#32 2012-04-26 00:46:49

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

If we could create a XOR operator (using only Scratch blocks)...

here you go
I made it specifically for 8 bit decimal sequences, but just change how many times it loops and it will work for any length.


Fork Clamor on GitHub!

Offline

 

#33 2012-04-26 01:17:09

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

itsmomito: That's actually really cool! It seems quite fast as well. Even though it is a shift-cipher, that's really good! Have you looked at Deffie's Key-Exchange protocol? That's the method we'll be using to create the key.  smile

I'm trying to decide what numbers to use (I don't know how to calculate primitive roots and all my math teachers either don't know or say it's too complicated for me). I know of two from an example one though: p=157, g=5. So if you could base your key generator on those values (the Deffie exchange explains how the random integers should be chosen).

ohaiderstudios: Thank you! Next we need a letter to binary now. One that supports all the letters on the keyboard, all 0-255 won't work because Scratch doesn't support them all very well.  big_smile

Also, for everyone: I suggest making all the variables private (except for three, input1, input2, and output, make sure they are unique like "xor_input1") so it doesn't collide with any other sprites/variables and stuff. That way it's easily implementable into projects.  smile

I'm going to see about working on a server plugin (for Scratch Space) that can be used to test Secure Mesh.

Offline

 

#34 2012-04-26 02:34:03

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

itsmomito: That's actually really cool! It seems quite fast as well. Even though it is a shift-cipher, that's really good! Have you looked at Deffie's Key-Exchange protocol? That's the method we'll be using to create the key.  smile

I'm trying to decide what numbers to use (I don't know how to calculate primitive roots and all my math teachers either don't know or say it's too complicated for me). I know of two from an example one though: p=157, g=5. So if you could base your key generator on those values (the Deffie exchange explains how the random integers should be chosen).

ohaiderstudios: Thank you! Next we need a letter to binary now. One that supports all the letters on the keyboard, all 0-255 won't work because Scratch doesn't support them all very well.  big_smile

Also, for everyone: I suggest making all the variables private (except for three, input1, input2, and output, make sure they are unique like "xor_input1") so it doesn't collide with any other sprites/variables and stuff. That way it's easily implementable into projects.  smile

I'm going to see about working on a server plugin (for Scratch Space) that can be used to test Secure Mesh.

Hmmm Okay then

Offline

 

#35 2012-04-26 20:13:15

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

Okay, another update! I've ported the Deffie Key-Exchange from a Python script to Scratch. You can see it here.

For some reason only numbers between 1-5 work (might be larger like 1-7, but I've only verified 1-5). alice_key and bob_key need to match each other. I used billyward's (I think that's his username) power algorithm. Any ideas on how to increase the limit from 1-5 to something larger like 1-1000? Also, if you don't mind, could you give me the numbers from alice_sint and bob_sint when the two keys match?

A couple things I modified, was that I added a round() around the power() algorithm. That may be a reason why, but sometimes I get numbers like "-1.42345879" or other e^## results, without a round() function around it.

I'll experiment some more and report my results later.

Last edited by Magnie (2012-04-26 20:15:49)

Offline

 

#36 2012-04-27 11:38:25

SJRCS_011
Scratcher
Registered: 2011-02-07
Posts: 1000+

Re: Scratch Cryptography

Umm, can we use BYOB for the contest?
Cause I've developed a hashing algorithim in BYOB that does it at the bit level.

Last edited by SJRCS_011 (2012-04-27 11:39:26)


http://i.imgur.com/vQqtH.png
Learning to Program in a Nutshell:  "You're missing a closing parentheses" - LS97

Offline

 

#37 2012-04-27 13:02:10

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

SJRCS_011 wrote:

Umm, can we use BYOB for the contest?
Cause I've developed a hashing algorithim in BYOB that does it at the bit level.

Sure! Each contest will be for a different mod. So Panther, BYOB, etc.

Offline

 

#38 2012-04-27 15:20:50

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

Okay, another update! I've ported the Deffie Key-Exchange from a Python script to Scratch. You can see it here.

For some reason only numbers between 1-5 work (might be larger like 1-7, but I've only verified 1-5). alice_key and bob_key need to match each other. I used billyward's (I think that's his username) power algorithm. Any ideas on how to increase the limit from 1-5 to something larger like 1-1000? Also, if you don't mind, could you give me the numbers from alice_sint and bob_sint when the two keys match?

A couple things I modified, was that I added a round() around the power() algorithm. That may be a reason why, but sometimes I get numbers like "-1.42345879" or other e^## results, without a round() function around it.

I'll experiment some more and report my results later.

Sorry Magnie, I couldn't figure out the solution to your problem when I took a look. Actually, i tried making the deffie key encryption too. It works but I don't know if I did it right, I will upload it soon.

Edit: Here is my attempt  http://scratch.mit.edu/projects/itsmomito/2500310  smile  If the output isn't the input then press the flag a few times

Last edited by itsmomito (2012-04-28 16:56:45)

Offline

 

#39 2012-04-28 20:28:49

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography


Fork Clamor on GitHub!

Offline

 

#40 2012-04-28 23:15:36

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

Sweet! This is coming along quite nicely!

itsmomito: Good job with the encryption system. Sometimes a couple of letters decrypt a letter off (like d instead of e).

ohaiderstudios: Thanks! That should help a ton!

I also just realized that Blowfish uses S-Boxes, which I have no idea what those are. So I'm afraid we'll have to use something else.

Offline

 

#41 2012-04-29 19:54:39

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

While putzing around Wikipedia, I discovered a method of hashing called CRC.

After studying it for a while, I made a similar function using Python:

Code:

class remaen():
    """
    Returns a hashing object, optionally initialized with a string.
    """
    def __init__(self, txt=""):
        self.s = txt
    def update(self, txt):
        """
        Append data to the hash value
        """
        self.s += txt
    def hexdigest(self):
        """
        Returns a 128-bit hexadecimal string
        """
        self.k = []
        for self.i in self.s:
            self.t = bin(ord(self.i)).split("b")[1]
            while len(self.t) < 8:
                self.t = "0" + self.t
            self.k.append(self.t)
        for self.i in range(128):
            self.k.append("0")
        self.k = [self.i for self.i in "".join(self.k)]
        while len(self.k) > 128:
            while self.k[0] == "0":
                self.k.pop(0)
            if len(self.k) < 129:
                break
            self.t = ""
            for i in range(129):
                self.t += self.k.pop(0)
            self.r = bin(int(self.t, 2) ^ 0x1345e414d7294b9a209b23b0972968d33).split("b")[1]
            self.k.insert(0, self.r)
            self.k = [self.i for self.i in "".join(self.k)]
        while len(self.k) < 128:
            self.k.insert(0, "0")
        self.h = []
        for self.i in range(32):
            self.t = self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0)
            self.t = hex(int(self.t, 2)).split("x")[1]
            self.h.append(self.t)
        return "".join(self.h)
    def digest(self):
        """
        Returns a 128-bit binary string
        """
        self.k = []
        for self.i in self.s:
            self.t = bin(ord(self.i)).split("b")[1]
            while len(self.t) < 8:
                self.t = "0" + self.t
            self.k.append(self.t)
        for self.i in range(128):
            self.k.append("0")
        self.k = [self.i for self.i in "".join(self.k)]
        while len(self.k) > 128:
            while self.k[0] == "0":
                self.k.pop(0)
            if len(self.k) < 129:
                break
            self.t = ""
            for i in range(129):
                self.t += self.k.pop(0)
            self.r = bin(int(self.t, 2) ^ 0x1345e414d7294b9a209b23b0972968d33).split("b")[1]
            self.k.insert(0, self.r)
            self.k = [self.i for self.i in "".join(self.k)]
        while len(self.k) < 128:
            self.k.insert(0, "0")
        self.h = []
        for self.i in range(16):
            self.t = self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0) + self.k.pop(0)
            self.t = chr(int(self.t, 2))
            self.h.append(self.t)
        return "".join(self.h)

Now to port it to Scratch...


Fork Clamor on GitHub!

Offline

 

#42 2012-05-01 21:28:35

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Scratch Cryptography

New one: shift cypher.
http://scratch.mit.edu/projects/GeonoTRON2000/2508540
If you want a decrypter, make one yourself.  It hurts my brain just to look at that.


http://i.imgur.com/BAEgGDL.png

Offline

 

#43 2012-05-01 22:56:39

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

GeonoTRON2000 wrote:

New one: shift cypher.
http://scratch.mit.edu/projects/GeonoTRON2000/2508540
If you want a decrypter, make one yourself.  It hurts my brain just to look at that.

Haha, I just responded to your comment with asking you to make one. xD

Offline

 

#44 2012-05-02 10:28:11

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: Scratch Cryptography

Magnie wrote:

GeonoTRON2000 wrote:

New one: shift cypher.
http://scratch.mit.edu/projects/GeonoTRON2000/2508540
If you want a decrypter, make one yourself.  It hurts my brain just to look at that.

Haha, I just responded to your comment with asking you to make one. xD

XP I just switched the +es for -es, and then it worked.


http://i.imgur.com/BAEgGDL.png

Offline

 

#45 2012-05-05 15:25:46

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

Bump.

Sorry I haven't been active lately, I have a lot of stuff to work on at school.


Fork Clamor on GitHub!

Offline

 

#46 2012-05-05 17:55:07

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

ohaiderstudios wrote:

Bump.

Sorry I haven't been active lately, I have a lot of stuff to work on at school.

CRTs are coming up, that's how life is. So no worries.  wink

I've come up with an encryption idea. What happens, is you convert the text to binary then you take the first 8 bits of the string and the first 8 bits of the key, stick them together, cut off the first 4 bits and the last 4 bits. Then you move on to the next 8 bits, and repeat the process until you finish.

I'm thinking of XORing something somewhere, but I don't know.

Offline

 

#47 2012-05-05 22:19:07

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

ohaiderstudios wrote:

Bump.

Sorry I haven't been active lately, I have a lot of stuff to work on at school.

CRTs are coming up, that's how life is. So no worries.  wink

I've come up with an encryption idea. What happens, is you convert the text to binary then you take the first 8 bits of the string and the first 8 bits of the key, stick them together, cut off the first 4 bits and the last 4 bits. Then you move on to the next 8 bits, and repeat the process until you finish.

I'm thinking of XORing something somewhere, but I don't know.

How exactly would you decrypt...?

It seems like you would be losing too much data.

Last edited by ohaiderstudios (2012-05-05 22:19:36)


Fork Clamor on GitHub!

Offline

 

#48 2012-05-05 23:43:00

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Cryptography

ohaiderstudios wrote:

Magnie wrote:

ohaiderstudios wrote:

Bump.

Sorry I haven't been active lately, I have a lot of stuff to work on at school.

CRTs are coming up, that's how life is. So no worries.  wink

I've come up with an encryption idea. What happens, is you convert the text to binary then you take the first 8 bits of the string and the first 8 bits of the key, stick them together, cut off the first 4 bits and the last 4 bits. Then you move on to the next 8 bits, and repeat the process until you finish.

I'm thinking of XORing something somewhere, but I don't know.

How exactly would you decrypt...?

It seems like you would be losing too much data.

No idea. I haven't gotten that far yet. xD

Why is it that all my awesome ideas fall short? I had an awesome compression idea but when I tried to create it, it didn't work.  sad

Offline

 

#49 2012-05-06 11:58:59

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

Magnie wrote:

ohaiderstudios wrote:

Magnie wrote:

CRTs are coming up, that's how life is. So no worries.  wink

I've come up with an encryption idea. What happens, is you convert the text to binary then you take the first 8 bits of the string and the first 8 bits of the key, stick them together, cut off the first 4 bits and the last 4 bits. Then you move on to the next 8 bits, and repeat the process until you finish.

I'm thinking of XORing something somewhere, but I don't know.

How exactly would you decrypt...?

It seems like you would be losing too much data.

No idea. I haven't gotten that far yet. xD

Why is it that all my awesome ideas fall short? I had an awesome compression idea but when I tried to create it, it didn't work.  sad

sad
99% of my ideas end up in failure as well.
That's just a part of the life of a programmer I guess...


Fork Clamor on GitHub!

Offline

 

#50 2012-05-07 19:50:13

ohaiderstudios
Scratcher
Registered: 2010-10-31
Posts: 100+

Re: Scratch Cryptography

I'm actually on the verge of a MAJOR breakthrough on Cascade, my encryption system I'm writing in Python.

Ohaider
Chief Theoretical Cryptographer


Fork Clamor on GitHub!

Offline

 

Board footer