Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forcing unsigned calculations
#21
Got it. Thanks! Tongue
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#22
Zack...I don't know exactly what you have in mind, but the logical operators work on the underlying bits, so sign doesn't really matter. For example, suppose we are talking about 16-bit integers...
a = 0
b = not a
b = -1 = 1111111111111111
---------------------------------------


a = 10 = 1010
b = not a
b = -11 = 1111111111110101
_________________________


The b0011an operators don't give a rat's ass if a number is signed or not...they deal strictly in bits. So...for not and xor, QB not supporting unsigned data-types (other than the 8-bit integer) won't hurt you.

So...don't worry about bytes...read the file as a series of integers and operate on these...then write your encrypted file, again as integers. (note you may have to pad your output to get everything to line up). Then make your unencrypter also deal with native integers (again, you may have to make provisions for the last bytes of the file in case they don't fit into an even numbers of words). In any case, your encrypter shouldn't care if the file is text, an exe, or a bitmap...and the output should look indistinguishable from a random bit-stream to any attacker...
Reply
#23
But my problem still stands: I'm CHR$()ing the result...And the result turns out to be negative. So, stil,l there is a problem.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#24
PB code: (implied bit arrays!)

Code:
FUNCTION PBMAIN() AS LONG
DIM z%(1 TO 2000)
BIT SET z%(1), 31984
MSGBOX STR$(z%(2000))
END FUNCTION
'result = 1
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#25
Haven't studies PB yet. I guess I should, that's AWESOME!
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#26
Quote:But my problem still stands: I'm CHR$()ing the result...And the result turns out to be negative. So, stil,l there is a problem.

My point is...why not do your underlying manipulations to the integers instead of bytes?? It will be much faster. There's nothing you can do to a byte that you can't do as well to a word.

An aside...to be any good a crypto-system has to stand up *EVEN* when an attacker has your source code!!!

EDIT...to expose myself to criticism...Here's my convoluted crypto-mess.....
http://home.bellsouth.net/p/PWP-brightwave



Cheers
Reply
#27
Oh, I see what going on with Zacks code! Mango, you're a genius!

Zack:
Code:
something1 = CHR$(&HFF AND (NOT (ASC(something1) XOR ASC(something2))))
You're XORing two numbers. Each number's most significant 8 bits (out of 16 bits) are zero. The top 8 bits are zero in the result too, but then NOT sets those 8 most significant bits! And so the integer turns out to be negative because bit 15 is set.

Code:
00000000????????
XOR 00000000????????
--------------------
    00000000xxxxxxxx
NOT
--------------------
    11111111yyyyyyyy
We both forgot to mask out everything but the lower 8 bits that we're interested in!
Reply
#28
But...I'm using SINGLEs...so that's also 16 bits?
That means I'll be ANDing the whole thing with 65535, right?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#29
No single is 32bit(4byte).
Reply
#30
So...ANDing with 4294967295, then?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)