Re: New encryption thread
- Posted by Hawke' <mdeland at GEOCITIES.COM> Dec 14, 1998
- 373 views
> function probil (integer key, integer data) > .. some processing here.. > .. return a result unique to the data, though not to the key. > .. So, different data-integers with the same key should never ever > return the same value > return my_integer > end function my first thoughts, a rough draft if you will, based upon my understanding of what you desire, which, at this point, is not a very strong understanding as (and, this is *not* anyone's "fault") i'm having a wee bit of trouble with your phraseology, a cultural, grammatical, translation difficulty... i _think_ i know what u want... for any given X and Y, return Z such that: for any X, Z may or may not be the same; however; for any X *and* Y, Z may never be the same. with that, my first draft is rather fast to process, easy to implement, and I believe satisfies the desire. the caveat and the problem I am having is not knowing just how large Y might be. If Y is approaching 2^31, or -2^31, then applying a numerical transformation to it can become problematic, and may trigger EU to return an *atom*... I can get around this with extra processing time, and since this is likly to be *inside* a loop, I would like to -avoid- that, like a plague. A simple algorithm (that may overflow) might be: func prob(int key, int data) set_rand(key) return rand(data) + rand(data) end func very fast, clean, neat, and I do not believe that for any given X & Y, that Z could *ever* be the same. if you limit data to ~2^15 or less, you have your algorithm. if we add a check inside the func to prevent overflow, it will slow this down, and that slowdown may propagate. const max = power(2,15) func prob(int key, int data) set_rand(key) if (data > max) then data = floor(data/rand(4)) return rand(data) + rand(data) end if if (data < -max) then data = floor(data/rand(4)) return rand(data) + rand(data) end if return rand(data) + rand(data) end func this is "more complex" *looking*, but, is short-circuited to help defeat speed penalties. the ole' get out while the getting is good... the largest problem with this algorithm is the use of set_rand, as, if you have already set the seed, *before* calling the func prob(), then I destroy that seed, and since (I WISH!) there is no function that retrieves the current seed, {no seed = get_rand() command...} I cannae store the state prior to calling set_rand()... the next largest problem with the algorithm, is that it won't work in reverse... ;) so, we can solve almost all the above with the extremely simple, (sans the single issue of set_rand) algorithm: func prob(int k, int d) set_rand(k) return xor_bits( rand(d), rand(d) ) end func this, unless i'm very sadly mistaken, which, so far, in dealing with topics of crypto, i've been very mistaken, often :) (hi Ad! see? we aren't so far apart... trust me, we all go thru growing pains while learning new 'topics', and I for one, do hope that your final line: >So, maybe in a week or two you will hear >from me again, or maybe never again. comes to pass as the *first* option... someone once said: Never stop questioning. ) will *never* produce the same return for different values of d, (unless d is very small... like 1 or 2... but give it ranges from ohhhh 100..2^31 and -100..-2^31, and u got no worries) but would return the same value if k and d were sent to it twice... and, it will always process in the same amount of ticks... </endRoughDraft> thoughts? _/ _/ _/_/_/ _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/ _/_/_/ _/ _/ _/_/ _/_/ _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/ _/ _/ _/_/_/ ({<=----------------------------------------=>}) ({<=- http://members.xoom.com/Hawkes_Hovel> -=}) ({<=----------------------------------------=>})