(42S) Hill's Encryption System
11-24-2014, 07:39 PM (This post was last modified: 06-15-2017 01:48 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,461 Joined: May 2014
(42S) Hill's Encryption System
Hill’s ciphering algorithm can be accomplished on the HP 42S using the following programmes.

To use:

1. Actuate programme HILL to set parameters.
2. ENCY encodes the alpha register, returning the coded message to the alpha register.
3. DECY decodes the alpha register, returning the clear message to the alpha register.

0. { 33-Byte Prgm }
1. LBL “R10”
2. RAN
3. SF 25
4. RCL “RMAX”
5. FC?C 25
6. 10
7. *
8. IP
9. RAN
10. 0.5
11. –
12. SIGN
13. *
14. END

Produces one random integer element of the ciphering matrices.

0. { 43-Byte Prgm }
1. LBL “LTRI”
2. ENTER
3. NEWMAT
4. EDIT
5. LBL 00
6. RCLIJ
7. X=Y?
8. GTO 01
9. XEQ “R10”
10. →
11. GTO 00
12. LBL 01
13. SIGN
14. STOEL
15. STOIJ
16. I+
17. FC? 76
18. GTO 00
19. CLX
20. EXITALL
21. END

Forms a lower triangular square matrix for integer input
Eg 3 LTRI returns a 3*3 LT matrix.

0. { 22-Byte Prgm }
1. LBL “MMOD”
2. EDIT
3. LBL 00
4. RCL ST Y
5. MOD
6. →
7. FC? 77
8. GTO 00
9. EXITALL
10. END

Makes the matrix in X-register modulo the integer in the Y-register
Eg 7 matrix MMOD returns the matrix modulo 7.

0. { 34-Byte Prgm }
1. LBL “A→M”
2. ALENG
3. RCL/ ST Y
4. ENTER
5. FP
6. X>0?
7. SIGN
8. +
9. X<>Y
10. NEWMAT
11. EDIT
12. LBL 00
13. R↓
14. ATOX
15. →
16. FC? 77
17. GTO 00
18. EXITALL
19. END

Converts the alpha-register contents to a matrix of integers of column dimension the X-reister
Eg 3 A→M returns a 3-coumn matrix.

0. { 95-Byte Prgm }
1. LBL “HILL”
2. INPUT “RMAX”
3. INPUT “SHIFT”
4. INPUT “CYMOD”
5. INPUT “MSIZE”
6. XEQ “LTRI”
7. ENTER
8. ENTER
9. TRANS
10. *
11. RCL “CYMOD”
12. X<>Y
13. XEQ “MMOD”
14. STO “INMAT”
15. R↓
16. X<>Y
17. FIX 00
18. INVRT
19. RND
20. ALL
21. ENTER
22. TRANS
23. X<>Y
24. *
25. XEQ “MMOD”
26. STO “OUTMAT”
27. END

Eg For capitals in to capitals out:

Alpha to alpha: SHIFT 65
CYMOD 26

For any character in to any character out:

All to all: SHIFT 0
CYMOD 256

0. { 85-Byte Prgm }
1. LBL “ENCY”
2. RCL “INMAT”
3. GTO 00
4. LBL “DECY”
5. RCL “OUTMAT”
6. LBL 00
7. ENTER
8. DIM?
9. X<>Y
10. R↓
11. XEQ “A→M”
12. X<>Y
13. *
14. RCL+ “SHIFT”
15. RCL “CYMOD”
16. X<>Y
17. XEQ “MMOD”
18. RCL+ “SHIFT”
19. LBL “M→A”
20. CLA
21. XTOA
22. AVIEW
23. END

ENCY encodes the alpha-register & DECY decodes the alpha-register.
 « Next Oldest | Next Newest »

 Messages In This Thread (42S) Hill's Encryption System - Gerald H - 11-24-2014 07:39 PM

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