How do I encrypt the alphabet into a series of numbers for encryption.
I've actually made a program that does just that, and quite speedy too. Here's the link:
http://www.ticalc.org/archives/files/fileinfo/407/40738.html

The way that most people do it is like this:

Code:
``` If str1 = "A" Then 1 -> L1(B If str1 = "B" Then 2-> L1(B If..... ```

But a much speedier way to do it is this:

Code:
``` " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" -> Str0 ... inString(Str0,sub((The string containing the text),B,1)) ->L1(B ```

That is the way to turn text right into numbers based on their character positions in the list. If you want better encryption, then you could add a random or chosen number or use an even better cipher.

Happy Coding!
Thanks so much man Ive been wondering so much about this . And Kerm now I get it.
Noobs helping noobs? What is the world coming to?
(just kidding..)

Yup, that's exactly it. At one point I toyed with a more real encryption, using the rand function.
We know that by seeding the random number generator (X->rand) you can obtain the same known series of 'random' numbers, so I used that. The user supplies a seed, then we create a list of the first 26 (or whatever) numbers that that seed produces. Then compare to the alphanumeric comparison string ("ABC...123"). Basically (Str1 is the input string, pi is our seed in this case. Outputs to L2):

Code:
``` :pi->rand :For(A,1,26) ::rand->L1(A) ::End :For(A,1,length(Str1)) ::"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str2 ::L1(inString(Str2,sub(Str1,A,1)))->L2(A) ::End ```

Not optimized, closing parens included for readability. Decryption is something like the reverse of that. If you prompt for the seed, you effectively have a password-protected string. Conceivably, you could figure something out to convert a string to your seed for even more security (words much easier to remember than a float, so users don't just choose 2 or something).
You guys should use the seq( instead of the For( loops.
That would work even better if you used something between L1 and L6 instead - you'd save three bytes for every list name mention.
Here's another encryption program with ALOT better security i call CIPHER. It uses a special alternating bit cipher to encrypt the data and uses the same model as CODEM (I'm too lazy to make a full sized version)

Code:
``` Ans -> (Theta) "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(theta).?!,'(Pi)" ->Str0 DelVar LDelVar BInput "Code:",Str1 length(Str1) -> L If (Theta) Then Input "Text:",Str2 For(A,1,length(Str2 B+1 -> B If B>L 1 -> B inString(Str0,sub(Str1,B,1))-1+inString(Str0,sub(Str2,A,1)) -> L1(A End L1 -> LCPR DelVar L Else " " -> Str2 For(A,1,dim(LCPR B+1 -> B If B>L 1 -> B Str2+sub(Str0,LCPR(A)-(inString(Str0,sub(Str1,B,1))-1),1) -> Str2 End Pause Str2 End DelVar Str0DelVar Str1DelVar Str2 ```

it asks you for a numerical key then asks for the text and dumps it into LCPR
Or, if you want some real encryption, here is a program that I wrote to do RSA encryption; this version is only 8-bit, so it is pretty bad. However, it should be simple to modify it to use up to 40 bit encryption (I wrote one at one point, but cannot find it); the encryption speed would actually be increased significantly by using 40 bit encryption over 8-bit.

Actually, the thing that I am most proud of writing for this program is my beast algorithm (actually, I doubt it's original, but I came up with the idea by myself) for computing a^b (mod c) for very large numbers a, b, and c.

Code:
```:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZθ .,?()/*-+^:!→Str2 :While 1 :¦ ClrHome :¦ Disp "RSA"," Encrypt"," Decrypt :¦ Output(5,4,"Powered By   Penguin Studios    Technology :¦ 2→X :¦ Repeat max(Ans={105,21,45 :¦ ¦ If Ans :¦ ¦ Output(X,1," :¦ ¦ X+(Ans=34 or Ans=25→X :¦ ¦ If Ans=4 :¦ ¦ 2→X :¦ ¦ Output(X,1," :¦ ¦ getKey :¦ End :¦ If Ans=45 :¦ Then :¦ ¦ ClrHome :¦ ¦ Disp "Thanks For","Using! :¦ ¦ Return :¦ End :¦ If X=2 :¦ Then :¦ ¦ ClrHome :¦ ¦ ".→Str5 :¦ ¦ Input "Public Key?",C :¦ ¦ Input "e?",Fv :¦ ¦ Input "Message?",Str1 :¦ ¦ ClrHome :¦ ¦ For(L,1,length(Str1 :¦ ¦ ¦ inString(Str2,sub(Str1,L,1→A :¦ ¦ ¦ If not(Ans :¦ ¦ ¦ Then :¦ ¦ ¦ ¦ Disp "Invalid: :¦ ¦ ¦ ¦ Output(1,9,sub(Str1,L,1 :¦ ¦ ¦ ¦ Return :¦ ¦ ¦ End :¦ ¦ ¦ Fv→B :¦ ¦ ¦ prgmE :¦ ¦ ¦ {0,D→L3 :¦ ¦ ¦ {D,0→L4 :¦ ¦ ¦ LinReg(ax+b)L3,L4,Y1 :¦ ¦ ¦ Equ►Str(Y1,Str6 :¦ ¦ ¦ Str5+sub(Str6,5,length(Str6)-4)+".→Str5 :¦ ¦ End :¦ ¦ Disp "Encoded Message: :¦ ¦ Pause Str5 :¦ ¦ Else :¦ ¦ ClrHome :¦ ¦ Repeat 1=N,E :¦ ¦ ¦ Input "1st Private?",M :¦ ¦ ¦ Input "2nd Private?",N :¦ ¦ ¦ Input "e?",E :¦ ¦ ¦ Input "Message?",Str1 :¦ ¦ ¦ (N-1)(M-1→N :¦ ¦ End :¦ ¦ " →Str3 :¦ ¦ NM→C :¦ ¦ 2→I% :¦ ¦ 1→PV :¦ ¦ Repeat not(fPart(PV/E :¦ ¦ ¦ PV+N→PV :¦ ¦ End :¦ ¦ PV/E→Fv :¦ ¦ Repeat not(PMT :¦ ¦ ¦ inString(Str1,".",I%→PMT :¦ ¦ ¦ If PMT :¦ ¦ ¦ Then :¦ ¦ ¦ ¦ expr(sub(Str1,I%,PMT-I%→A :¦ ¦ ¦ ¦ 1+PMT→I% :¦ ¦ ¦ ¦ Fv→B :¦ ¦ ¦ ¦ prgmE :¦ ¦ ¦ ¦ Str3+sub(Str2,D,1→Str3 :¦ ¦ ¦ End :¦ ¦ End :¦ ¦ ClrHome :¦ ¦ Disp "Message Decoded! :¦ ¦ Pause Str3 :¦ End :End```

The above is for the main program; it uses a sub program, E to compute a^b (mod c) (though I cannot remember the actual variables atm)

Code:
```:1→D :round(CfPart(A/C),0→A :√(A→E :1+int(log(B)/log(2→Z :ClrListL1 :ClrListL2 :Ans→dim(L1 :Ans→dim(L2 :For(I,Z-1,0,‾1 :¦ If 2^I≤B :¦ Then :¦ ¦ B-2^I→B :¦ ¦ 1→L1(I+1 :¦ End :¦ round(CfPart(E2/C),0→E :¦ Ans→L2(Z-I :End :For(I,Z,1,‾1 :¦ If L1(I :¦ round(CfPart(DL2(I)/C),0→D :End```

The main problem with the code (and BASIC in general) is that I have to constantly round the results to insure that they are integers

Finally, my Math Program has built in encrypting and decrypting functions for the basic type of converting.
About the rounding, I think in these cases you don't have to put the ",0" at the end, because a 9-digit round should be enough to make it an integer with those small differences.
cool but it looks like all he wants is code that changes a string into a list and back...

:Seq(inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", Str1),A, 1, length(Str1))-->L1

And

:" "--> Str1
:For (N,1, dim(L1))
:Str1 + sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",L1(N),1) -->Str1
:End
:sub(Str1,2,dim(L1))--> Str1

of course this limits you to strings that are shorter than 999 characters and takes up a ridiculous amount of ram. Honestly there really is no point conveting strings to lists except perhaps for storing a username or something which is still pretty useless...

Now that I think about it I wrote a program called VarZip a while back which turns strings into lists that take up less memory than the original string, particularly when you use lowercase...
well it is most useful for saving high scores because that way you don't have to worry about the names being over written if another program uses that same str also you can test for a lists existence where as if a str doesn't exist and you try to modify it you'll get an error.
Oh so as in associating a name with a high score?

This is slightly off topic but i really dont see the point of associating a name with a high score if its not going to be written to the program itself and sent... because the person who owns the calculator is pretty much the only person to play it.... but I guess I see your point...

...I'm possibly feeling slightly indecisive...
True, and yet the practice of putting one's initials with his or her high scores in calculator games persists to this day. I add that, if I were you.
Well if you just want to save intials you could just forget strings and simply save the keys...

:ClrHome
:For (N,1,2
:DelVar A
:While A<40
:GetKey -->A
:End
:Output(1,N,sub("abc defgh ijklm...", A-40,1
:A --> L1(N
:End
:2--> dim(L1

Hmm its longer than I thought it would be but regardless I think it would be shweeter from both a prograamer and user perspective because 1.) dont have to press second, alpha or enter 2.) don't have to add saving for lowercase letters which takes up more space and 3.) you now have the ability to add all sorts of cool things to it =D

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum