Post Reply 
(HP 41) Encryption of messages
08-28-2021, 08:42 AM (This post was last modified: 09-01-2021 02:51 AM by rawi.)
Post: #1
(HP 41) Encryption of messages
This program allows to encrypt and decrypt messages.

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.
Only characters are used that can be easily accessed by the keyboard.
After putting in the character and pressing R/S you are shown the encrypted (or decrypted) character and you can input the next character and press R/S

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 -> K (K is the encryption for T at that place). Next letter overwrites the encryption.
-> H R/S -> N -> E R/S -> / -> (Space) R/S -> D …

The whole phrase encrypted as follows:
KN/DFC/03J1*.71T6T2R

Note that the same character is transformed to different encrypted characters like the first A from Calculator to C and the second to 1. Note that as well the same character in the encrypted phrase can be different characters in the not encrypted phrase like the first “/” stands for E and the second for L. Furthermore space is coded as well so that length of words cannot be used to decipher.

Decryption:
XEQ alpha CRYP alpha
-> SEED? To decrypt we have to take the same number: PI 3 – R/S
-> ENC = 1 DEC = 2? We want to decrypt, therefore:2 R/S
-> CHAR? We type K (the first letter of the encrypted phrase) R/S -> T (the first letter of the not encrypted phrase) -> N R/S -> E -> / R/S -> (space) …

Note: If no character is shown this stands for space.
Method:
For every character a random number generator is used to encrypt it. So the meaning of a character is position sensitive.
The random number generator is in lines 28-32. It has the form: r(n) = Frac(9821*r(n-1)+0.211327).
It was taken from the HP Standard Programs Book for the HP 34C.

Enjoy!

Code:

01 LBL alpha CRYP alpha
02 Alpha SEED? Alpha
03 PROMPT
04 STO 00
05 Alpha ENC=1 DEC=2? Alpha
06 PROMPT
07 STO 01
08 AON
09 Alpha CHAR? Alpha
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 RCL 00
29 9821
30 *
31 .211327
32 +
33 FRC
34 STO 00
35 44
36 *
37 1
38 +
39 INT
40 XEQ IND 01
41 31
42 +
43 32
44 X<>Y
45 X<=Y?
46 GTO 04
47 9
48 +
49 58
50 X<>Y
51 X<=Y?
52 GTO 04
53 6
54 +
55 LBL04
56 XTOA
57 STOP
58 GTO 00
59 LBL 01
60 +
61 44
62 X<>Y
63 X<=Y?
64 RTN
65 X<>Y
66 -
67 RTN
68 LBL 02
69 -
70 X>0?
71 RTN
72 44
73 +
74 RTN
75 END
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)