This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's General Open Topic subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Open Topic & United-TI Talk => General Open Topic
Author Message
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 02 Dec 2008 11:57:35 pm    Post subject:

Hey weregoose!! I need your help. I need help to design a prgm that will take text and use a table that can be changed, to encode the text and display the encoded version. it would help if it could decode the encoded text too.
for ex
a b c d e f g h i j k l m n o p q r s t u v w x y z
f g h i j k l m n o p q r s t u v w x y z a b c d e

the top row would represent a letter from the original message.
the bottom row would represent that letter when its been encoded.

visa versa for decoding.
-thanks
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 03 Dec 2008 03:57:53 am    Post subject:

im not weregoose but...

"abcdefghijklmnopqrstuvw
sub(ans,26*fpart( (instring(ans,str1) - 5)/26),1


where str1 holds a single letter

of course, you should omit the * sign...

if you want to decode a string of 2 or more chars:


"abcdefghijklmnopqrstuvw -> str2
for(a,1,lengt(str1
ans + sub(str2,26*fpart( (instring(str2,sub(str1,a,1)) - 5)/26),1
end
text(0,0,ans


probaly...

edit: i just released it typed the alpabet wrong... Cool


Last edited by Guest on 12 Jul 2010 01:46:43 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Dec 2008 07:47:06 am    Post subject:

*sigh* How about providing a program that doesn't crash?

crackingthecode, what you are describing is a Caesar cipher with a five-letter offset. That can be carried out with the following...

    "ABCDEFGHIJKLMNOPQRSTUVWXYZ
    For(X,1,length(Str1
    Ans+sub(Ans,1+round(26fPart((inString(Ans,sub(Str1,X,1))+N-1)/26)),1
    End
    sub(Ans,27,X-1


...with the message in Str1 and N equal to five. You can decode it by storing 26-5 to N to reverse the offset.

Welcome to United-TI! :)

[EDIT]

Ah, I knew that there was an improved way of doing this: Click


Last edited by Guest on 12 Jul 2010 01:48:03 am; edited 1 time in total
Back to top
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 04 Dec 2008 08:15:38 pm    Post subject:

Very Happy i dont mean just the caeser cipher, but mono-alphabetic substitution. one letter subs another letter once. i mean like to change it up...
-thanks for the help though
Back to top
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 04 Dec 2008 10:54:29 pm    Post subject:

by the way, weregoose, im sort of new to the terminology. could you please break it down a bit more, so i understand more fully.
thanks- i appreciate it

my current idea is: //str1 is plaintext //str2 is cipher //str3 is ciphertext ps the format of the str2 is abcdefghijklmnopqrstuvwxyz then the cipher:qwertyuiopasdfghjklzxcvbnm
so the str2=abcdefghijklmnopqrstuvwxyzqwertyuiopasdfghjklzxcvbnm
a=q b=w...

while x is less than or equal to length(str1)
If inString(Str2,sub(str1,x,x,))=0
then
sub(str1,x,x,)+str3 store str3
else
instring(str2,sub(str1,x,x)) store L
L+26 store L
sub(str2,L,L)+str3
ans store str3
x+1 store x
end
disp str3

Im getting nowhere with the errors, so HELP
thanks


Last edited by Guest on 04 Dec 2008 11:36:13 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 05 Dec 2008 12:45:26 am    Post subject:

Oh. Okay, well, let's break it down with a simpler program. This will take a message in Str3 and encode it to Str4 by converting each letter in Str1 to the corresponding letter in Str2:

" ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str1
Store the plaintext alphabet.

" NIBQPKYUWCRMOZGVEHFSDLAJTX→Str2
Store the ciphertext alphabet.

Input Str3
Get the message to be encoded.

"?→Str4
Prepare the string that will hold the encoded message.

For(X,1,length(Str3
Set X equal to 1 and start looping with X increasing until it reaches the length of Str3.

sub(Str3,X,1→Str5
Extract the next letter from the message using X.

inString(Str1,Str5→P
Get the position of this letter as it appears in the plaintext alphabet.

sub(Str2,P,1→Str6
Extract the letter at the same position from the ciphertext alphabet.

Str4+Str6→Str4
Add this letter to the encoded string.

End
Mark the end of the loop.

sub(Str4,2,length(Str4)-1→Str4
Remove the ? from the encoded string.

Now, you should realize that are a few ways to improve this – I'll let you present the results of doing so to yourself, however. The basic rule on this one is to use Ans, make a substitution, and repeat.


Last edited by Guest on 12 Jul 2010 01:48:41 am; edited 1 time in total
Back to top
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 05 Dec 2008 12:51:37 am    Post subject:

Thanks alot. That makes so much more sense. im glad i was refered to you.

so to decode, i switch str1 and str2?




By the way, what was wrong with my previous program?


Last edited by Guest on 05 Dec 2008 01:07:24 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 05 Dec 2008 01:01:34 am    Post subject:

I merged your two posts. Please wait something more like an hour before making a double post, thanks. :)

After testing it in the program above, switching Str1 and Str2 in the first and second lines only does indeed turn the encoder into a decoder.


Last edited by Guest on 12 Jul 2010 01:49:48 am; edited 1 time in total
Back to top
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 09 Dec 2008 09:21:44 am    Post subject:

hey weregoose, i made my own program, but i need your help. it won't encode the whole cypher, just the first letter, and sometimes not even that.

"?>str1
"?>str3
"?>str7
if length(str2) does not equal 52
then
"abcdefghijklmnopqrstuvwxyz">str2
goto C
else
MEnu("Choose a option", "encode", E, "decode", D, "Edit cpiher", C, "quit", Q)
lbl C
clrhome
input "Type cipher ", str7
if length(str7) does not equal 26
then
pause "wrong length"
goto C
else
for(x,1,length(str7)
inString(str7,sub(str7,x,1), x +(x does not equal length(str7)))>L
if l does not equal 0
then
pause "duplicate letter
goto C
else
end
sub(str2,1,26)+str7>str2
prgmCODEN
Lbl E
clrhome
input "enter plaintext", str1
1>x
lbl L
while x is less than or equal to length(str1)
instring(str2,sub(str1,x,1))>L
if L<1 or L>26
then
str3+sub(str1,x,1)>str3
x+1>x
goto L
else
L+26>L
str3 + sub(str2, L, 1) > str3
x+1>x
end
sub(str3,2,length(str3)-1>str3
sub(str2,27,26)
clrhome
Output(1,1,ans
output(3,2,str3
stop
lbl D
'This is the decode section that works.
Lbl Q
stop

any help would be appericated.
(i need it asap for school)
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 09 Dec 2008 09:56:34 am    Post subject:

I see the problem, or at least a pontential problem if length(str2) does not equal 52
then
"abcdefghijklmnopqrstuvwxyz">str2
goto C Memory leak!!
else
Menu("Choose a option", "encode", E, "decode", D, "Edit cpiher", C, "quit", Q)
lbl C

When you jump out of a If Then End set, the Basic Parser Is still looking for an End so it might skip otherwise usefull code. Plus, it causes a memory leak and slows it down. You should rearrange the code.


Last edited by Guest on 12 Jul 2010 01:46:25 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 09 Dec 2008 05:29:39 pm    Post subject:

Because this code stops making sense by the time it reaches the first label, I'm going to ask you to rewrite it. Leave out everything except for the bare essentials—no menus, no error catching, and no fancy outputs—and we'll work on adding the small details from there. Okay? Smile

Last edited by Guest on 09 Dec 2008 05:31:50 pm; edited 1 time in total
Back to top
GloryMXE7
Puzzleman 3000


Active Member


Joined: 02 Nov 2008
Posts: 604

Posted: 09 Dec 2008 06:04:02 pm    Post subject:

Quote:
'This is the decode section that works

decoding is basicaly swithcing the plaintext alphabet with the cypher alphabet then encoding the already encoded message using the swiched alphabets right so it would be easy to optimize the program by only using the decode part but when encoding dont swich the alphabets before hand

oh and heres some help with symbols you dont have on your keyboard

does not egual sign: !=
store: ->
less than or equal to: <=
Greater than or equal to: >=


Last edited by Guest on 09 Dec 2008 06:13:36 pm; edited 1 time in total
Back to top
ticalcnoah


Member


Joined: 28 Oct 2007
Posts: 153

Posted: 09 Dec 2008 06:18:56 pm    Post subject:

Here are even better ones.
→ ≠ ≥ ≤
Back to top
crackingthecode


Newbie


Joined: 02 Dec 2008
Posts: 8

Posted: 09 Dec 2008 10:00:39 pm    Post subject:

thanks for the help, but with the help of stranger, i was able to fix the errors just enough for the deadline. ill type the program soon so that you guys can help me shrink it down some more.
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 10 Dec 2008 09:47:57 am    Post subject:

ticalcnoah wrote:
Here are even better ones.
→ ≠ ≥ ≤
[post="130120"]<{POST_SNAPBACK}>[/post]


Lol I prefer ==, != and the rest... No mess with copy-paste! :biggrin:
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 10 Dec 2008 01:29:40 pm    Post subject:

→ = Alt+26, or any 26+256n. Pleasant results are 26, 282, 1818, and 10010.

≥ = Alt+242 or 242+256n, and nice ones are 1010 and 7666; add 1 to get ≤.

≠ = Typing charmap into Run..., or having it handy elsewhere for copy+paste.
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 10 Dec 2008 01:55:13 pm    Post subject:

Oh yeah, the charmap. I only use it for my greek font. (characters /w spirituses and accents)

And my charmap is broken, it doesn't display the keystrokes anymore...
Back to top
Display posts from previous:   
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.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement