Qbasicnews.com

Full Version: QBasic Challenge :-)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Ladies and Gentlemen, Boys and Girls, the ultimate challenge has arisen! You are going to create a progam that will take a document (.txt or other) and specialy encrypt it. Also needed is a decrypter that will decrypt the document as well! You will be the king of internet privicy :king:

E-mail or PM me by, umm lets see :roll: February 14 2004

:bounce: GOODLUCK :bounce:
QB encryption program 1.03
Simple text encryption by Paul Malcher
Encryption program by Chris Pulley
Encrypt by Adam Perry & Matt Ochs
Crypt by Strategy Surplus
Crypter by Lucas Alonso
File Crypt by Eric McCormick
Hey-Cody by The WebKid
Xor encryption/decryption by Jonathan Leger
Xor encryption by Scott Turchin

Is there something in particular you are looking for that is different from the above programs? Maybe a few more details could help us out in developing something you want to see. Wink
yes, are there any specific rules you have to follow?
Dum de dum...Ok, here's mine:
Code:
DIM inbyte AS STRING*1
DIM outbyte AS STRING*1
INPUT "Code to use:";code
OPEN "infile.txt" FOR BINARY AS #1
OPEN "outfile.txt" FOR BINARY AS #2
DO UNTIL EOF(1)
GET #1,inbyte
outbyte=CHR$(ASC(inbyte) XOR code)
PUT #2,outbyte
NEXT
CLOSE #1,#2
There you go. Very simple, very WEAK XOR encryption. I've built a few pretty strong encryption algos, but I don't have the time to go modifying them to QB now.
And to decrypt:
Code:
DIM inbyte AS STRING*1
DIM outbyte AS STRING*1
INPUT "Code to use:";code
OPEN "outfile.txt" FOR BINARY AS #1
OPEN "outfile2.txt" FOR BINARY AS #2
DO UNTIL EOF(1)
GET #1,inbyte
outbyte=CHR$(ASC(inbyte) XOR code)
PUT #2,outbyte
NEXT
CLOSE #1,#2
Cheers.
[EDIT]Note that you use the same code(1-255) you entered to encrypt the file, to decrypt it.
There are no specific guidlines, just a program that can encrypt and decrypt. And ummm....technically, the first person is Zack, but lets see who can make one that wasn't previously made.
Fine, fine...I'll make a stronger encryption algo.
I'll work on it later. So disregard my previous submission. I'll post the new one later.
OK, here it is:
Quote:CLS
DIM inbyte AS STRING * 1
DIM outbyte AS STRING * 1
INPUT "File to encrypt: ", infile$
INPUT "File to send encrypted chars to: ", outfile$
INPUT "Code to use: ", code
OPEN infile$ FOR BINARY AS #1
OPEN outfile$ FOR BINARY AS #2
DO UNTIL EOF(1)
GET #1, , inbyte
outbyte = CHR$((ASC(inbyte) XOR code) XOR (code - 3))
PUT #2, , outbyte
LOOP
And the code you use to encrypt is the same you use to decrypt (use the very same program to decrypt it).
[EDIT] Oh yeah, the code you enter needs to be between 4 and 255.
is that the same thing but subtracting 3 from the inputted code

edit: nvm
edit: my version?
edit2:updated
edit3:mwahaha updated again >_>
Code:
CLS
DIM inbyte AS STRING * 1
DIM outbyte AS STRING * 1
INPUT "File to encrypt: ", infile$
INPUT "File to send encrypted chars to: ", outfile$
INPUT "Code to use: ", code
OPEN "c:\progra~1\qbasic4.5\qbfiles\encrypt\" + infile$ FOR BINARY AS #1
OPEN "c:\progra~1\qbasic4.5\qbfiles\encrypt\" + outfile$ FOR BINARY AS #2
DO UNTIL EOF(1)
SELECT CASE code
CASE IS >= 255: code = 4
CASE IS < 4: code = 4
CASE ELSE: code = code + 1
END SELECT
GET #1, , inbyte
outbyte = CHR$((ASC(inbyte) XOR code))
FOR i = 1 TO 3
outbyte = CHR$((ASC(outbyte) XOR (code - i)))
NEXT
PUT #2, , outbyte
LOOP
CLOSE
Hmmmn. I could have post my Bac superior text compression program... but since that is secret... Wink

However, here's a bit swapper:
Code:
'$DYNAMIC
DEFINT A-Z

COLOR 15
PRINT "Bit Swapper"
PRINT "By Neo Deus Ex Machina" + CHR$(13) + "-----------------------"
COLOR 7

INPUT "Input file to (de)compress:", InFile$
INPUT "Input file to write to:", OutFile$
InFile$ = LTRIM$(RTRIM$(UCASE$(InFile$)))
OutFile$ = LTRIM$(RTRIM$(UCASE$(OutFile$)))

Encrypted = 0

InF = FREEFILE
OPEN InFile$ FOR BINARY AS #InF
   OutF = FREEFILE
   OPEN OutFile$ FOR BINARY AS #OutF

      Header$ = SPACE$(7)
      GET #InF, , Header$
      IF Header$ = STRING$(3, 26) + "NDEM" THEN Encrypted = NOT(0)
      SEEK #InF, 1

      IF Encrypted THEN
         SEEK #InF, 8
      ELSE
         Header$ = STRING$(3, 26) + "NDEM"
         PUT #OutF, 1, Header$
      END IF

      DIM Byte AS STRING * 1, NewByte AS STRING * 1
      flen& = LOF(InF)
      IF Encrypted THEN flen& = flen& - 7
      got& = 0

      CLS 'clear screen for progress bar
      PRINT "Busy..."

      IF NOT Encrypted THEN
         DO UNTIL got& >= flen&
            GET #InF, , Byte
            IF got& = 0 THEN
               FrontNib% = (ASC(Byte) AND &HF0) \ &H10
               BackNib% = (ASC(Byte) AND &HF)
            ELSE
               FrN% = (ASC(Byte) AND &HF0) \ &H10
               BkN% = (ASC(Byte) AND &HF)
               NewByte = CHR$((BackNib% * &H10) OR FrN%)
               PUT #OutF, , NewByte
               BackNib% = BkN%
            END IF

            got& = got& + 1
            LOCATE 2, 1
            perc% = INT(got& / flen& * 80)
            PRINT STRING$(perc%, 219) + STRING$(80 - perc%, 176)
         LOOP
         IF got& > 0 THEN
            NewByte = CHR$((BackNib% * &H10) OR FrontNib%)
            PUT #OutF, , NewByte
         END IF

      ELSEIF Encrypted THEN

         DO UNTIL got& >= flen&
            IF got& = 0 THEN
               SEEK #InF, 7 + flen&
  
               GET #InF, , Byte
               BackNib% = (ASC(Byte) AND &HF)
               SEEK #InF, 8
            ELSE
               GET #InF, , Byte

               FrN% = (ASC(Byte) AND &HF0) \ &H10
               BkN% = (ASC(Byte) AND &HF)
               NewByte = CHR$((BackNib% * &H10) OR FrN%)
               PUT #OutF, , NewByte
               BackNib% = BkN%

               got& = got& + 1

               LOCATE 2, 1
               perc% = INT(got& / flen& * 80)
               PRINT STRING$(perc%, 219) + STRING$(80 - perc%, 176)

            END IF

         LOOP

      END IF

   CLOSE #OutF
CLOSE #InF

This code was completely written down from the top of my head. I didn't test it using QB. Perhaps there are some bugs, but this is due to not having tested it. Hope it works Big Grin

EDIT: Someone able to test this? Thanks.
Whitetiger: No, no: First I XOR the character-code with the code user enters. Then I re-encrypt it by XORing it with the code user enters, minus 3.
Hence double-encryption.
(BTW I've made a very strong encryption algo...I call it 2D encryption, because there are two encrypted characters for every character that you encrypt. I've yet to find a way to decrypt it, though.)
Neo: Goodness! I didn't test that, but it looks very strong.
Pages: 1 2 3