Re: [GENERAL] Feistel cipher, shorter string and hex to int

2009-07-07 Thread Daniel Verite
Ivan Sergio Borgonovo wrote: I need shorter values (because they should be easier to type. To be sure to modify the function in a sensible way I really would appreciate some pointer. Still if it return What exactly is your desired range of output values? Best regards, -- Daniel

Re: [GENERAL] Feistel cipher, shorter string and hex to int

2009-07-07 Thread Daniel Verite
Ivan Sergio Borgonovo wrote: r2:=l1 # 1366.0*r1+150889)%714025)/714025.0)*32767)::int; -- but what about this? where does it come from? This function: (1366.0*r1+150889)%714025 implements a known method to get random numbers. I think it comes from Numerical recipes by William

Re: [GENERAL] Feistel cipher, shorter string and hex to int

2009-07-07 Thread Ivan Sergio Borgonovo
On Tue, 07 Jul 2009 12:07:48 +0200 Daniel Verite dan...@manitou-mail.org wrote: Ivan Sergio Borgonovo wrote: r2:=l1 # 1366.0*r1+150889)%714025)/714025.0)*32767)::int; -- but what about this? where does it come from? This function: (1366.0*r1+150889)%714025 implements a

Re: [GENERAL] Feistel cipher, shorter string and hex to int

2009-07-07 Thread Daniel Verite
Ivan Sergio Borgonovo wrote: I don't get the 1366.0 and the 714025.0. Writing 1366.0 isn't going to use float arithmetic? Yes, that's on purpose. Now that you mention it, I think that 1366.0 could be an integer instead, but the division by 714025 and multiplication by 32767 have to

[GENERAL] Feistel cipher, shorter string and hex to int

2009-07-06 Thread Ivan Sergio Borgonovo
On Sat, 02 May 2009 11:26:28 +0200 Daniel Verite dan...@manitou-mail.org wrote: Note that it returns a bigint because we don't have unsigned integers in PG. If you're OK with getting negative values, the return type can be changed to int. Otherwise if you need a positive result that fits in