(Comp.sys.handhelds) Item: 3696 by Simone.Rapisarda at wolf.sublink.org Author: [Simone Rapisarda] Subj: new CODER Date: Tue Jul 16 1991 Sorry but the version of CODER that I posted some days ago doesn't work fine. Excuse me if it caused any problem to you. Here is the correct version and this time it's in commented user RPL because of the few 'exercise to the reader' of the past days. :) Thanks to Jurjen that showed me the problems with CODER and that showed me also that is not really impossible to find the key. --------------- Do you keep any top-secret data in your 48 ? If yes, the following program will be very useful to you. C O D E R --------- STRING CODER & DECODER by Simone Rapisarda CODER requires two arguments: a string to de/code on level two and a cipher key-string on level one. If the arguments are not strings CODER will change them into strings before coding. The two strings can be of any length; the longer the cipher key, the safer the result string. If the cipher key-string is longer than the string to de/code it will be truncated. The algorithm used is very simple. The program is only 60 bytes long. The coding of a 1000 characters string with a 5 characters cipher key takes about .2 seconds. USAGE 1 |3: | |3: | |2: "String to Code"| |2: | |1: "Cipher Key"| ----> |1: "Coded String"| |CODER ### ### ### ### ### | |CODER ### ### ### ### ### | +--------------------------+ +--------------------------+ USAGE 2 |3: | |3: | |2: "String to Decode"| |2: | |1: "Cipher Key"| ----> |1: "Decoded String"| |CODER ### ### ### ### ### | |CODER ### ### ### ### ### | +=====---------------------+ +--------------------------+ Here it is. ------8<------8<------- %%HP: T(3)A(D)F(.); \<< \->STR SWAP \->STR @ Makes sure the two arguments are strings. DUP SIZE ROT @ Size of the string to de/code. WHILE DUP2 SIZE > @ Do it until the two sizes are equal. REPEAT DUP + @ Doubles the length of the key string. END 1 ROT SUB XOR @ Makes sure the two strings are of equal \>> @ length then finally code them. ------8<------8<------- ciao RAP -- WolfNet BBS Pisa (Italy) Tel. +39-50-589050 300-14.4K Baud Matrix 2:332/602.0 Simone Rapisarda - via FidoNet node 2:33/800 UUCP: ...!gear!wolf!Simone.Rapisarda ARPA: Simone.Rapisarda@wolf.sublink.org ---------- Resp: 1 of 1 by cloos at acsu.buffalo.edu Author: [James H. Cloos] Date: Tue Jul 16 1991 22:51 Lines: 159 Being the (original definition!) hacker type, I tend to rewrite a lot of programs I get off the net into internal rpl for my own use. I thought this one might be a good example to show how that is done with the new (NOMAS) development system. Above, you see the userlang version of a simple cipher program. Below is a rpl version, using only the fixed words as described in the entries.a file in the development system distribution. [Note: It is Jim's version that's on this disk. -jkh-] ** coder.s ** From userlang routine by Simone Rapisarda ASSEMBLE NIBASC /HPHP48-D/ RPL :: CK2NOLASTWD DO>STR SWAP DO>STR DUPLEN$ ROT BEGIN 2DUP LEN$ #> WHILE DUP &$ REPEAT ONE ROT SUB$ XOR$ ; Normally, of course, you'd run this thru RPLCOMP, SASM, and SLOAD, but given its short size, I found it actually easier to hand compile into the following, in ASCI acceptable format (in the latest version of HACKIT, at least): "D9D20 @ :: D8A81 @ CK2NOLASTWD 88041 @ DO>STR 32230 @ SWAP 88041 @ DO>STR BB726 @ DUPLEN$ 59230 @ ROT 2A170 @ BEGIN CA130 @ 2DUP 63650 @ LEN$ 38D30 @ #> EE170 @ WHILE D9D20 @ :: 88130 @ DUP 3915D @ &$ B2130 @ ; 5E170 @ REPEAT 9FF30 @ ONE 59230 @ ROT 33750 @ SUB$ B9881 @ XOR$ B2130 @ ; " Notice that as only a single object can be between the WHILE and REPEAT, the two words I wanted to put there had to be encased in a :: ; pair. This is, of course, done for you by RPLCOMP. If anyone wants to type this in and use ASC\->, rather than ASCI\->, it would look like: "D9D20D8A81880413223088041BB726592302A170CA1306365038D30EE170D9D2 0881303915DB21305E1709FF305923033750B9881B2130B386" With the systems docs at hand, you shouldn't have any trouble converting routines. Just be sure to do them a small bit at a time. And also note than you can come back, after you have the routines working, and replace things like DUP LEN$ with words like DUPLEN$ that combine those functions; you do not have to worry about them at first. Keep a copy of entries.a handy, and you can look up all of your word pairs and see if a combo word is available to do that. As Bill said (@ least I *think* it was he), I [also] hope to see a lot of good, interesting programs showing up here. Happy developing! -JimC -- James H. Cloos, Jr. Phone: +1 716 673-1250 cloos@ACSU.Buffalo.EDU Snail: PersonalZipCode: 14048-0772, USA cloos@ub.UUCP Quote: <>