Crypting and decrypting text messages

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
rawi
Posts: 42
Joined: Sat Dec 28, 2019 4:50 am
Location: Bavaria, Germany

Crypting and decrypting text messages

Post by rawi »

With this program you can crypt and decrypt text messages.
This is the DM 42 version of a DM 41 X program that can be found here: viewtopic.php?f=30&t=3095

Application:
At the beginning you are asked for the starting value of the random number generator: SEED?
Take any number between 0 and 1.
The same number has to be used for encryption and decryption.
Then you are asked whether you want to encrypt or to decrypt ENC=1 DEC=2?
Put in 1 for encryption, 2 for decryption.
Then you are asked for a character. You can use any of the following 44 characters:
Space * + , - . / : 0 to 9 A to Z
Then you are shown the encrypted or decrypted character and you can input the next character.

Example: We want to encrypt and decrypt the following phrase: THE CALCULATOR FORUM
XEQ alpha CRYP alpha
-> SEED? We take Pi – 3: PI 3 – R/S
-> ENC = 1 DEC = 2? We want to encrypt, therefore: 1 R/S
-> CHAR? -> T R/S -> 0 (0 is the encryption for T at that place). Next letter overwrites the encryption.
-> H R/S -> K -> E R/S -> X -> (Space) R/S -> J …

The whole phrase encrypted is as follows:
0KXJKKXYXYIDC*.NNJFB

For every character a random number generator is used to encrypt it. So the meaning of a character is position sensitive. As a consequence the same character can be transformed to different encrypted characters like the first A from Calculator to K and the second to I. Note that as well the same character in the encrypted phrase can transform to different characters in the not encrypted phrase like the first X stands for E and the second for L.

Decryption:
XEQ alpha CRYP alpha
-> SEED? We take again Pi – 3: PI 3 – R/S
-> ENC = 1 DEC = 2? We want to decrypt, therefore:2 R/S
-> CHAR? We type 0 (the first letter of the encrypted phrase) R/S -> T (the first letter of the not encrypted phrase) -> K R/S -> H -> X R/S -> E -> J R/S -> (space) …
Note: If no character is shown this stands for space.

Code: Select all

00 { 131-Byte Prgm }
01▸LBL "CRYP42"
02 "SEED?"
03 PROMPT
04 SEED
05 "ENC=1 DEC=2?"
06 PROMPT
07 STO 01
08 AON
09 "CHAR?"
10 PROMPT
11▸LBL 00
12 ATOX
13 31
14 -
15 1
16 X<>Y
17 X≤Y?
18 GTO 03
19 9
20 -
21 18
22 X<>Y
23 X≤Y?
24 GTO 03
25 6
26 -
27▸LBL 03
28 RAN
29 44
30 ×
31 1
32 +
33 IP
34 XEQ IND 01
35 31
36 +
37 32
38 X<>Y
39 X≤Y?
40 GTO 04
41 9
42 +
43 58
44 X<>Y
45 X≤Y?
46 GTO 04
47 6
48 +
49▸LBL 04
50 XTOA
51 STOP
52 GTO 00
53▸LBL 01
54 +
55 44
56 X<>Y
57 X≤Y?
58 RTN
59 X<>Y
60 -
61 RTN
62▸LBL 02
63 -
64 X>0?
65 RTN
66 44
67 +
68 RTN
69 END
Attachments
cryp42.raw
(134 Bytes) Downloaded 12 times
Post Reply