NAME: Pseudo asymmetric cipher
CREATOR: ?
PB AUTHOR: Tim Wisseman
DESCRIPTION: A demo algorithm that uses different keys for encrypting/decrypting.
NOTES: This is not a true asymmetric cipher.
SOURCE: http://www.powerbasic.com/support/forums/Forum6/HTML/001845.html
Viewing source from pseudoasym.bas   675 bytes   Last modified Wed, 20 September 2006

'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")

Back to The Archives