Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text Encryption-Decryption
#2
A better way to do that is with a Seeded Random value and XOR ing the bytes.   It's pretty simple and the Random Number seed is the required key for decryption 

Code: (Select All)

Print
Print "ENTER A STRING TO ENCRYPT"
Line Input X$
Print
Print "STARTING STRING"
Print X$
Print

GETSEED:
Input "ENTER A SEED VALUE"; SEED

If SEED = 0 Then Print "INVALID SEED TRY AGAIN": Print: GoTo GETSEED
If SEED > 0 Then SEED = SEED * -1
X = Rnd(SEED)

CRYPT$ = ""
For I = 1 To Len(X$)
MASK = Int(Rnd(1) * 255) + 1
C$ = Mid$(X$, I, 1)
C = Asc(C$)
CRYPTBYTE = (C Or MASK) And Not (C And MASK): Rem XOR
CRYPT$ = CRYPT$ + Chr$(CRYPTBYTE)
Next

Print "ENCRYPTED"
Print
Print CRYPT$
Print
X$ = ""

GETSEED2:
Input "ENTER THE SAME SEED TO DECRYPT"; NEWSEED

If NEWSEED = 0 Then Print "INVALID SEED TRY AGAIN": Print: GoTo GETSEED2
If NEWSEED > 0 Then NEWSEED = NEWSEED * -1

X = Rnd(NEWSEED)

For I = 1 To Len(CRYPT$)
MASK = Int(Rnd(1) * 255) + 1
C$ = Mid$(CRYPT$, I, 1)
C = Asc(C$)
CRYPTBYTE = (C Or MASK) And Not (C And MASK): Rem XOR
X$ = X$ + Chr$(CRYPTBYTE)
Next

Print "DECRYPTED"
Print
Print X$
Print



Reply


Messages In This Thread
Text Encryption-Decryption - by 2112 - 10-16-2025, 07:27 PM
RE: Text Encryption-Decryption - by ahenry3068 - 10-17-2025, 12:01 AM
RE: Text Encryption-Decryption - by ahenry3068 - 10-17-2025, 12:07 AM
RE: Text Encryption-Decryption - by madscijr - 10-17-2025, 04:34 AM
RE: Text Encryption-Decryption - by bplus - 10-17-2025, 11:55 AM
RE: Text Encryption-Decryption - by ahenry3068 - 10-17-2025, 02:03 PM
RE: Text Encryption-Decryption - by euklides - 10-21-2025, 11:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Text Effects 2 2112 6 659 10-30-2025, 11:13 PM
Last Post: Unseen Machine
  Upside-Down Big Text SierraKen 2 673 02-22-2025, 01:52 AM
Last Post: SierraKen
  Exercise with picture and text Kernelpanic 10 2,330 06-14-2024, 10:00 PM
Last Post: SMcNeill
  Word (text) processor krovit 19 4,399 09-02-2023, 04:38 PM
Last Post: grymmjack
  3D Orbiting Text SierraKen 4 1,167 08-03-2022, 05:40 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: 1 Guest(s)