Qbasicnews.com
July 02, 2020, 07:02:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3 4 ... 7
  Print  
Author Topic: FieldView encryption challenge  (Read 66014 times)
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #15 on: August 16, 2005, 11:32:10 AM »

Heres my first try... Uses a frequency setting like 2way radios, cept its used to scramble the string... pretty fast if you ask me, not sure if its good enough or not..

Edit: Most of the code is a speed test/example... :roll:

Code:
DECLARE SUB ScramleMsg(Msg AS STRING, Frq AS INTEGER)
DECLARE SUB DeScramleMsg(Msg AS STRING, Frq AS INTEGER)


'##################################################
'## EXAMPLE #####################
'##################################################
SCREEN 14, 32

Msge$ = "Hello, world! This is a example of my scrambler/encrypter! Testing with large string to see how fast this operates. One more sentance should do it for a nice test!"
COLOR RGB(255, 255, 255)
PRINT "Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
COLOR RGB(255, 255, 255)
PRINT "Press Key to scramble..."
SLEEP
CLS

ST1! = TIMER
'ScramleMsg(Message_String$, Frequency Setting)
' Returns string given scrambled...
' Scrable is set by a frequency type setting
ScramleMsg(Msge$, 100)
FT1! = TIMER
TT1! = FT1! - ST1!
PRINT "Scrambled Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
COLOR RGB(255, 255, 255)
PRINT "Press key to return message... "
SLEEP

ST2! = TIMER
'DeScramleMsg(Message_String$, Frequency Setting)
' Returns scrambled sting as it was before the scramble..
' Scrable is set by a frequency type setting
'  Frequency must be the same as the one used in the Scramble call...
DeScramleMsg(Msge$, 100)
FT2! = TIMER
TT2! = FT2! - ST2!
PRINT "Unscrambled Message: ";
COLOR RGB(255, 255, 0)
PRINT Msge$
PRINT
PRINT
COLOR RGB(255,255,255)
PRINT "Total Scrambling time:";
COLOR RGB(0, 255, 0)
PRINT TT1!
PRINT ST1!; " <- Started.."
PRINT FT1!; " <- Finished."
PRINT
COLOR RGB(255,255,255)
PRINT "Total DeScrambling time:";
COLOR RGB(0, 255, 0)
PRINT TT2!
PRINT ST2!; " <- Started.."
PRINT FT2!; " <- Finished."
SLEEP
'##################################################
'################################
'##################################################

SUB ScramleMsg(Msg AS STRING, Frq AS INTEGER)
    FOR i = 1 TO LEN(Msg)
        S$ = MID$(Msg, i, 1)
        N = ASC(S$)
        N = (N + Frq)MOD 255
        STORE$ += CHR$(N)
    NEXT
    Msg = STORE$
    STORE$ = ""
END SUB

SUB DeScramleMsg(Msg AS STRING, Frq AS INTEGER)
    FOR i = 1 TO LEN(Msg)
        S$ = MID$(Msg, i, 1)
        N = ASC(S$)
        N = (N - Frq)
        IF N < 0 THEN N = 255 - N
        STORE$ += CHR$(N)
    NEXT
    Msg = STORE$
    STORE$ = ""
END SUB
Logged

Kevin (x.t.r.GRAPHICS)

anarky
Been there, done that
*****
Posts: 1231


The Blobworld Comics King


« Reply #16 on: August 16, 2005, 11:34:50 AM »

Total scrambling time: 0
Total unscrambling time: 0

Either not very accurate timer, or blinding fast.

>anarky
Logged

Screwing with your reality since 1998.
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #17 on: August 16, 2005, 11:39:12 AM »

Should be correct, I set a start time be4 calling the SUB, then collect the finishing time after the sub returns.. subtract the finish with the start to collect the total elapsed time...  :roll:
Logged

Kevin (x.t.r.GRAPHICS)

Neo
Na_th_an
*****
Posts: 2150



« Reply #18 on: August 16, 2005, 12:06:39 PM »

Quote from: "The Zire"
Come on cowards, more entries! Or are you scared!?

Not really. I didn't start yet but I will soon. Currently trying to make VBC faster so that it can compress your nice little messages.
Logged
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #19 on: August 16, 2005, 12:15:19 PM »

z!re, i had a link at the top of my post to a static lib version...  :roll:  :lol:  Cheesy  :wink:
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Z!re
*/-\*
*****
Posts: 4599


« Reply #20 on: August 16, 2005, 02:23:29 PM »

Quote from: "dumbledore"
z!re, i had a link at the top of my post to a static lib version...  :roll:  :lol:  Cheesy  :wink:
:oops: I overlooked the .a file Tongue

Neo, VBC?
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #21 on: August 16, 2005, 02:32:11 PM »

Quote from: "The Zire"
Neo, VBC?

Yes Zire, it's a headerless compression algorithm which I also wrote for NeoCL, but then it was in QB. I'm thinking of implementing that too so that your packages get smaller.
Logged
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #22 on: August 16, 2005, 03:54:40 PM »

btw, what's a julius caesar?
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Neo
Na_th_an
*****
Posts: 2150



« Reply #23 on: August 16, 2005, 04:10:50 PM »

In the Roman age, Julius Caesar used encryption to send messages to the warfront commanders without them being readable to anyone else.

He used the encryption where each character is converted to a character n letters away from it. In which n was a static number that differed for each commander he wrote to so that the commanders couldn't read eachother's letters to Caesar.
The simplest known Caesar encryption is the +1 Caesar, which works like:
HELLO
to:
IFMMP
(all letters are +1 letter further).
Logged
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #24 on: August 16, 2005, 04:37:56 PM »

XD..... Oops,.  :lol: .. that's what I just did....
Logged

Kevin (x.t.r.GRAPHICS)

dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #25 on: August 16, 2005, 10:28:00 PM »

Shocked
 :lol:
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #26 on: August 16, 2005, 10:56:55 PM »

Tongue Laugh it up... I did say it was my first go,.. I normaly do the oppisite with HTML or OBJ files... tho it doesn't really count.. those are easy...

Try try agian: This one displaces/encrypts the message acording to a password, then to top it off, rewrites the whole thing backward... makes a reall mess of things, but it cleans up good,.. never fear...  :lol: ... If it usless, the sub routines are at least comical...  Cheesy

Code:
DECLARE SUB ScrewUpMessage( MSG$, PASS$ )
DECLARE SUB FixUpMessage( MSG$, PASS$ )

'#######################################
MSG$ = "Hello, world. This is a better encrypter that not only scrambles to a given password, it reverses the encrypted message. ^_^,.."
PASS$ = "MyPassword"

PRINT "Message: "; MSG$
SLEEP
PRINT
ScrewUpMessage( MSG$, PASS$ )
PRINT "Encryption: "; MSG$
PRINT
SLEEP
FixUpMessage( MSG$, PASS$ )
PRINT "Decryption: "; MSG$
SLEEP
'######################################

SUB ScrewUpMessage( MSG$, PASS$ )
    NUM = LEN(PASS$)
    DIM CCard(NUM)
    FOR i = 1 TO NUM
        A$ = MID$(PASS$, i, 1)
        CCard(i) = ASC(A$)
    NEXT
    Cont = 0
    FOR i = 1 TO LEN(MSG$)
        cont = (cont + 1)MOD NUM
        IF cont = 0 THEN cont = 1
        B$ = MID$(MSG$, i, 1)
        LNUM = ASC(B$)
        C$ = STR$(LNUM + CCard(cont))
        STORE$ += CHR$(VAL(C$))
    NEXT
   
    Cont = LEN(STORE$)
    FOR i = 1 TO LEN(STORE$)
        D$ = MID$(STORE$, cont, 1)
        RSTORE$ += D$
        Cont -= 1
        IF Cont = 0 THEN EXIT FOR
    NEXT
    MSG$ = RSTORE$
    STORE$ = ""
    RSTORE$ = ""
END SUB

SUB FixUpMessage( MSG$, PASS$ )
    NUM = LEN(PASS$)
    DIM CCard(NUM)
    FOR i = 1 TO NUM
        A$ = MID$(PASS$, i, 1)
        CCard(i) = ASC(A$)
    NEXT
   
    Cont = LEN(MSG$)
    FOR i = 1 TO LEN(MSG$)
        D$ = MID$(MSG$, cont, 1)
        STORE$ += D$
        Cont -= 1
        IF Cont = 0 THEN EXIT FOR
    NEXT
   
    Cont = 0
    FOR i = 1 TO LEN(STORE$)
        cont = (cont + 1)MOD NUM
        IF cont = 0 THEN cont = 1
        B$ = MID$(STORE$, i, 1)
        LNUM = ASC(B$)
        C$ = STR$(LNUM - CCard(cont))
        RSTORE$ += CHR$(VAL(C$))
    NEXT
   
    MSG$ = RSTORE$
    STORE$ = ""
    RSTORE$ = ""
END SUB
Logged

Kevin (x.t.r.GRAPHICS)

KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #27 on: August 17, 2005, 03:08:12 AM »

Quote from: "whitetiger0990"
So you must have a time machine.


And thus I must be the most intelligent person in the entire world anyway, and so could always just write a superior encryption routine. MUUWAHAHAHAHAHAHAHAH!

But no time for that! Now I must go and service the TM1000. The flux capacitors need cleaning out and the quark filters need replaced.
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #28 on: August 17, 2005, 04:05:42 AM »

Quote from: "dark_prevail"
superior encryption routine.

Then do it Tongue
Yours is also a julius/caesar encryption... very superior Wink


Also:
People, what happens when the password given is longer than the message, is that taken into consideration?
Logged
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #29 on: August 17, 2005, 05:32:26 AM »

it is with mine  :wink:
Logged

ttp://m0n573r.afraid.org/
Quote from: "HexDude"
quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Pages: 1 [2] 3 4 ... 7
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!