Author Topic: Secure (Ish) Cipher  (Read 5442 times)

0 Members and 2 Guests are viewing this topic.

Offline JustCause

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 810
  • Rating: +115/-5
    • View Profile
Secure (Ish) Cipher
« on: December 01, 2010, 06:41:50 pm »
A simple example program that converts text to ciphertext and back again. Because it uses the rand seed, it's super-secure: unless someone knows it was coded on a calc, they're not getting it decoded.

Supports A-Z and spaces. Key can be any number.

Optimizations welcome.
« Last Edit: December 02, 2010, 10:45:17 am by JustCause »
See you, space cowboy...

SirCmpwn

  • Guest
Re: Super Secure Cipher
« Reply #1 on: December 01, 2010, 06:43:51 pm »
Removed voluntarily by author.
« Last Edit: December 02, 2010, 12:48:03 am by SirCmpwn »

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #2 on: December 01, 2010, 06:46:39 pm »
A simple example program that converts text to ciphertext and back again. Because it uses the rand seed, it's super-secure: unless someone knows it was coded on a calc, they're not getting it decoded.

Supports A-Z and spaces. Key can be any number.

Optimizations welcome.

The calc uses L'Ecuyer's algorithm. It's not a very secure pseudo random generator.
« Last Edit: December 02, 2010, 12:56:48 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Super Secure Cipher
« Reply #3 on: December 02, 2010, 12:50:37 am »
I do not know about encryption, but could you show examples of what would a certain word show up as when encrypted?

That said, although I think SirCmpwn's comment was uncalled for, it is pretty hard to have a secure encryption on a calc, even in BASIC. In my RPG The Reign of Legends 3, save files are compressed and encrypted using my own compression methods, but anyone who look at the code and understands BASIC could easily figure it out.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #4 on: December 02, 2010, 12:56:58 am »
 Looking at the code, that's actually a pretty good algorithm. What I would recommend is that you manipulate the strings during computation to take advantage of the avalanche effect in another way. It would also make it a lot more difficult to understand how the algorithm works. I have some example code I can post if you'd like.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Super Secure Cipher
« Reply #5 on: December 02, 2010, 03:20:03 am »
That would be cool :D

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #6 on: December 02, 2010, 03:24:02 am »
Now where did Battlefield go...

Ah, here it is:

Code: [Select]
:" →Str2
:" →Str1
:Repeat length(Str2)=7
:Repeat Ans>40 and Ans<94 or Ans=102
:getKey→K
:End
:If Ans≠44 and Ans≠45 and Ans<94:Then
:Ans-20-5int(.1Ans
:Str2+sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZ",Ans,1→Str2
:Text(26,2,sub(Str2,2,length(Str2)-1
:End
:If K=45 and length(Str2)>1:Then
:sub(Str2,1,length(Str2)-1→Str2
:Text(26,1,"                     "
:Text(26,1,Str2
:End
:If K=102:Then
:Str2+" →Str2
:Text(26,1,Str2
:End
:End


:sub(Str2,2,length(Str2)-1→Str2
:Text(26,2,Str2
:"TEYGJKMNOQRAUBCIVWDLEFHSZ "→Str3
:For(A,1,6
:Str1+sub(Str2,7-A,1)→Str1
:End
:sub(Str1,2,6→Str2
:For(A,1,6
:inString(Str3,sub(Str2,A,1→B
:length(Str3)→D
:(C-B)/(B+C)+B*C→C
:End

This is the reasonably fast algorithm I used in Battlefield. It's not the best one I had, but it's good enough. See if you can understand how it works.

Also, if following the program flow gives you a headache, you should have seen the previous version  :devil:

On a side note, this is about as close to SMC as you can get in BASIC without a ton of Goto statements.
« Last Edit: December 02, 2010, 03:37:59 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Super Secure Cipher
« Reply #7 on: December 02, 2010, 03:35:42 am »
I'll probably have to concentrate a bit to understand. I have troubles reading other people code. ;D

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #8 on: December 02, 2010, 03:37:40 am »
Following the String manipulation is the difficult part. Try to concentrate on the second part (after
":sub(Str2,2,length(Str2)-1→Str2")
« Last Edit: December 02, 2010, 03:38:28 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Super Secure Cipher
« Reply #9 on: December 02, 2010, 03:42:34 am »
I'll probably also have to run parts of the program a few times to analyze it, since I'm more visual. :P

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #10 on: December 02, 2010, 03:45:42 am »
Here's the routine in a BASIC program
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Super Secure Cipher
« Reply #11 on: December 02, 2010, 03:51:42 am »
Oh thanks that might save me some time lol, although since your code was in SourceCoder format (noticing the STO symbol used) I could have copied it on my calc. :D

Being visual is most likely what hindered me when I tried to learn ASM from ASM in 28 days D:

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Super Secure Cipher
« Reply #12 on: December 02, 2010, 03:54:04 am »
I already had the routine open in sourcecoder and that way everyone can try the code for themselves, rather than having to copy it into their calc.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline JustCause

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 810
  • Rating: +115/-5
    • View Profile
Re: Secure (Ish) Cipher
« Reply #13 on: December 02, 2010, 10:46:21 am »
Topic title changed. To be fair, when I said "secure" I meant "your crypto nerd friends will go at it for about a week," rather than "1024-bit RSA suitable for issues of national security."

Though I did make 16-bit RSA once. :)
See you, space cowboy...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Secure (Ish) Cipher
« Reply #14 on: December 02, 2010, 07:20:53 pm »
How long does a 16 bit key takes to get factored on-calc? What about a recent computer?