Pseudo asymmetric cipher
Algorithm creator(s)
n/a
PB author(s)
Tim Wisseman
Description
A demo algorithm that uses different keys for encrypting/decrypting.
Note
This is not a true asymmetric cipher.
Source
https://forum.powerbasic.com/forum/user-to-user-discussions/programming/18890-public-key-cryptography?t=18385
See also
n/a
Source Code
Download source code file pseudoasym.bas (Right-click -> "Save as ...")
'Assume:
' Public Key 125, 53
' Private Key 78, 13
DIM sMess AS STRING
DIM iMess AS INTEGER
DIM a AS INTEGER
DIM b AS INTEGER
DIM i AS INTEGER
'// The message we are sending is just "h"
sMess = "h"
iMess = ASC(sMess)
'// Public Key = 125 and 53
a = 125
b = 53
a = 112 XOR a
b = 123 XOR b
i = iMess XOR a
i = (i + b) MOD 255
'// Your secret message
PRINT "Your secert message is: "; STR$(i)
'// Your incoming message is 179
iMess = 179
'// Private Key = 78 And 13
a = 78
b = 13
i = (i - a) MOD 255
i = i XOR b
sMess = CHR$(i)
PRINT "decoded message is: "; sMess '("h")