Qbasicnews.com
July 02, 2020, 06:36:22 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 ... 5 6 [7]
  Print  
Author Topic: FieldView encryption challenge  (Read 66013 times)
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #90 on: August 23, 2005, 01:47:54 AM »

you and your silly null chars in your passwords @neo  :lol:
the problem was sending it a null password or data would cause a crash, since i use % and 0%0 = division by o Sad
btw, fixed. try it again:
http://m0n573r.afraid.org/libcryptc.zip
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
red_Marvin
Na_th_an
*****
Posts: 1509



WWW
« Reply #91 on: August 25, 2005, 05:42:31 PM »

An optimization of negligeable importance, but still it made a
~1.2Ás difference on 200byte strings...
[syntax="qbasic"]OPTION explicit
OPTION dynamic

DECLARE FUNCTION xorstring(msg AS STRING, KEY AS STRING) AS STRING

FUNCTION xorstring(msg AS STRING, KEY AS STRING) AS STRING
  DIM l AS INTEGER, n AS INTEGER
  l=LEN(KEY)-1
  FOR n=0 TO LEN(msg)-1
    msg[n]=msg[n] XOR KEY[n AND l]
  NEXT
  xorstring=msg
END FUNCTION
[/syntax]
Logged

/post]
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #92 on: August 26, 2005, 03:16:33 PM »

Quote from: "red_Marvin"
An optimization of negligeable importance, but still it made a
~1.2Ás difference on 200byte strings...
[syntax="qbasic"]OPTION explicit
OPTION dynamic

DECLARE FUNCTION xorstring(msg AS STRING, KEY AS STRING) AS STRING

FUNCTION xorstring(msg AS STRING, KEY AS STRING) AS STRING
  DIM l AS INTEGER, n AS INTEGER
  l=LEN(KEY)-1
  FOR n=0 TO LEN(msg)-1
    msg[n]=msg[n] XOR KEY[n AND l]
  NEXT
  xorstring=msg
END FUNCTION
[/syntax]


Standard argument passing mode in FB is by reference, which means, it passes the address of the argument (in this case, 'msg', the target string) itself, to this function. So you are actually modifying the string itself, passed to the function...so if you have a variable and pass it on that to this function, it will destroy this variable...not good. Just do this:

Code:

FUNCTION xorstring(argmsg AS STRING, KEY AS STRING) AS STRING
  DIM l AS INTEGER, n AS INTEGER
  Dim msg as String
  msg = argmsg
  l=LEN(KEY)-1
  FOR n=0 TO LEN(msg)-1
    msg[n]=msg[n] XOR KEY[n AND l]
  NEXT
  xorstring=msg
END FUNCTION


 Smiley
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
red_Marvin
Na_th_an
*****
Posts: 1509



WWW
« Reply #93 on: August 26, 2005, 05:51:17 PM »

you couldn't just declare the msg string like
BYVAL msg AS STRING
Or are strings always passsed as byref for some memory reason?
Logged

/post]
Deleter
Na_th_an
*****
Posts: 1293



WWW
« Reply #94 on: August 26, 2005, 06:35:37 PM »

Ok, here's mine. You use the same sub for encrypting/decrypting, which means you can't double/triple/etc.  encrypt.

Code:
Declare Function DEncrypt ( argText As String, argPassword As String ) As String

Dim password As String, text As String
text = "Hello, this is a test"
password = "Hello, this is a test"

Function DEncrypt ( argText As String, argPassword As String ) As String
    Dim seed As Integer
    Dim tempCount As Integer
    Dim tempText As String
    tempText = argText
   
    For tempCount = 0 To Len( argPassword ) - 1
        seed += argPassword[tempCount]
    Next tempCount
   
    Randomize seed
   
    For tempCount = 0 To Len( argText ) - 1
        tempText[tempCount] = ( argText[tempCount] Xor Int( Rnd * 256 ) )
    Next tempCount
   
    Return tempText
End Function
Logged

Anonymous
Guest
« Reply #95 on: August 26, 2005, 06:55:52 PM »

nice use of randomize... that thought never occurred to me
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #96 on: August 26, 2005, 07:29:08 PM »

I used it in one of my versions I posted before, like that.
Logged
Deleter
Na_th_an
*****
Posts: 1293



WWW
« Reply #97 on: August 27, 2005, 01:49:50 AM »

Quote from: "Neo"
I used it in one of my versions I posted before, like that.

exactly like that?  Sad
Logged

Anonymous
Guest
« Reply #98 on: August 27, 2005, 04:54:25 AM »

i think all the '@@@@@@@@' threw me off :lol: jk dont mind me
Logged
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #99 on: August 27, 2005, 01:31:43 PM »

Quote from: "red_Marvin"
you couldn't just declare the msg string like
BYVAL msg AS STRING
Or are strings always passsed as byref for some memory reason?


Yes, it would seem as all strings are passed byref regardless of any byval fixes...
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
dumbledore
Ancient Guru
****
Posts: 520



WWW
« Reply #100 on: August 27, 2005, 07:44:37 PM »

@neo: tried out my new ver?  Tongue
 :roll:  :barf:
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 #101 on: September 14, 2005, 03:32:46 AM »

Challenge is over..

Winner will be announced in QBE#14
Logged
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #102 on: September 14, 2005, 03:35:53 PM »

I wonder who won Shocked
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #103 on: September 14, 2005, 10:30:12 PM »

:rotfl:

Simple. Neo. He almost always wins challenges like this.  :wink:
Logged
Pages: 1 ... 5 6 [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!