Shop OBEX P1 Docs P2 Docs Learn Events
Data encryption — Parallax Forums

Data encryption

Helen CHelen C Posts: 34
edited 2006-07-06 19:53 in BASIC Stamp
·Hi,

I was wondering if anyone has implemented any kind of data encryption using a Stamp.· I have managed to find source code for TEA in assembly language and C but to be honest I don't really understand it!

Any suggestions please smile.gif

Cheers,
Helen

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-07-06 18:16
    Do you have a link to the source?
  • Helen CHelen C Posts: 34
    edited 2006-07-06 18:36
    Hi,

    The assembly code can be found at:

    http://www.8052.com/codelib/tea.a51

    and the C at
    http://www.ftp.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html
    Thanks
    Helen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-06 18:44
    HelenC,

    ·· What/where is the target data to be encrypted/decrypted?· A simple but powerful way of encrypting/decrypting data is to XOR each byte of data with the bytes of the password.· Once you run out of characters in the password, you loop it.· This way the password appears to be infinite and since the characters are handled one at a time, the result is that it's very difficult to decrypt.· For example...

    @2#5^89!0)··· <---This is the PASSWORD
    This is the DATA that I want to encrypt.· It's not very secure right now.

    The idea would be:

    T XOR @
    h XOR 2
    i XOR #
    s XOR 5
    (space) XOR ^
    i XOR 8
    s XOR 9
    (space) XOR !
    t XOR 0
    h XOR )
    e XOR @··· <--- Notice how when the password ends it loops...This adds to the security because the probability is that the looped password character that gets XORed with a different value (as is the case here) so you can't discern a pattern from that.

    An interesting effect of using XOR is that the same password used to encrypt is also used to decrypt the data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Helen CHelen C Posts: 34
    edited 2006-07-06 18:50
    Thanks Chris,

    I'll give it a try.

    Cheers, Helen
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-07-06 19:06
    I know this encryption method works since I wrote a DOS application based on it back in 1990 that was a big hit at a programming convention.· No "xxx-bit key" encryption.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 7/6/2006 7:34:32 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2006-07-06 19:53
    In addition to using the XOR method that Chris describes, another effective encryption method is 90-deg matrix rotation.

    In this case " This is the" would look like.....

    
    
    Normal Data:
    
    0101 0100 - T
    0110 1000 - h
    0110 1001 - i
    0111 0011 - s
    0010 0000 - (space)
    0110 1001 - i
    0111 0011 - s
    0010 0000 - (space)
    
    0111 0100 - t
    0110 1000 - h
    0110 0101 - e
    0000 0000 - (nul)
    0000 0000 - (nul)
    0000 0000 - (nul)
    0000 0000 - (nul)
    0000 0000 - (nul)
    
    
    Bits rotated 90 Deg clockwise:
    
    0000 0000 - (nul) 
    0110 1111 - o
    1111 1111 - (ASCII 255)
    0100 1001 - I
    0010 0110 - &
    0000 0001 - (soh)
    0100 1000 - H
    0110 1100 - l
    
    0000 0000 - (nul)
    0000 0111 - (bel)
    0000 0111 - (bel)
    0000 0001 - (soh)
    0000 0010 - (stx)
    0000 0101 - (enq)
    0000 0000 - (nul)
    0000 0100 - (eot)
    
    



    You could do the same thing at the NIBble level by rotating a 4x4 or even at the WORD level rotating a 16x16.
    Depending on a simple ODD or EVEN check you could rotate the DATA clockwise or counter clockwise.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
    576 x 425 - 115K
Sign In or Register to comment.