Recent

Author Topic: Blowfish help  (Read 12815 times)

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Blowfish help
« Reply #15 on: January 08, 2013, 12:14:31 pm »
There is propably some shl/shr bitshift way, but you can also use record.
Code: [Select]
TInt64Parts = record
  a, b: dword;
end;
...
var i64: int64; lowint: dword;
begin
  lowint:=TInt64Parts(i64).a;
Hope it works.

what about LARGE_INTEGER/ULARGE_INTEGER from windows unit.
It takes two 32 bit High, low and return 64bit quardpart result,
and vice versa.

Is there unsigned int 64 in freepascal.
Holiday season is online now. :-)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Blowfish help
« Reply #16 on: January 08, 2013, 12:22:35 pm »
Quote
here  64bit(qword) is to splitted into two 32bit(LongWord).
OK, I assume I misunderstood the documentation
Quote
does fpc/lazarus has some inbuilt function to split 64bit value into two 32 bit (longword) values. If yes, then it will be good as gold.
http://www.freepascal.org/docs-html/rtl/system/hi.html
http://www.freepascal.org/docs-html/rtl/system/lo.html

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Blowfish help
« Reply #17 on: January 09, 2013, 05:07:46 am »
Quote
here  64bit(qword) is to splitted into two 32bit(LongWord).
OK, I assume I misunderstood the documentation
Quote
does fpc/lazarus has some inbuilt function to split 64bit value into two 32 bit (longword) values. If yes, then it will be good as gold.
http://www.freepascal.org/docs-html/rtl/system/hi.html
http://www.freepascal.org/docs-html/rtl/system/lo.html

i had done in this way, converted from C language.

Code: [Select]
function _to64(xLeft,xRight: culong):cuint64;
begin
   Result := cuint64((cuint64(xLeft) shl 32) or xRight);
End;

procedure _to32(inValue : cuint64; out xLeft: culong; out xRight : culong);
begin
   xRight := culong(inValue and $FFFFFFFF);
   xLeft := culong(inValue shr 32);
end;

is this correct for freepascal. If yes, i would request you to suggest the lazarus team to include this is lazarus. It would be nice to have this function.
and if no please suggest me the right way.
Holiday season is online now. :-)

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Blowfish help
« Reply #18 on: January 09, 2013, 08:18:52 am »
Why everybody comming from c thinks that everithing starts and ends with c/c++.... and no other language / developers can have the same "genius" ideas / capabilities as c  >:D

so @deepaak99 : did you ever read the online help for hi() and lo() functions?


please do not insult us by suggesting  us to include some miracle from the c heaven ....

this 2 functions exists in pascal sice more that 30 year ...


 >:D >:D >:D >:D >:D >:D
Speak postscript or die!
Translate to pdf and live!

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Blowfish help
« Reply #19 on: January 09, 2013, 11:09:18 am »
Why everybody comming from c thinks that everithing starts and ends with c/c++.... and no other language / developers can have the same "genius" ideas / capabilities as c  >:D

Firstly, I am not insulting anyone out here.

Secondly, I am not even insulting pascal/freepascal.

Quote
so @deepaak99 : did you ever read the online help for hi() and lo() functions?

yes, i had read.

Quote
please do not insult us by suggesting  us to include some miracle from the c heaven ....

I am not insulting anyone, if any one had felt this, then i am extremely sorry for it.

But now, i want to ask you a simple question.
If Pascal is so good as C/C++ then why in any school/universities or colleges there is not an even single subject for pascal.

I know 'C/C++' is tough but, then also 'C' is the mother language. even most robust operating systems are written in  'C\C++' why not in pascal.

I truly believe pascal has lot of scope, and has improved a lot in recent years, and hope one day it will  get its real position in the entire world.


Quote
this 2 functions exists in pascal sice more that 30 year ...

i agree..

Quote
>:D >:D >:D >:D >:D >:D

please don't insult a programmer who has recently joined pascal. if you can promote him/her, then it is good,
because only source to study pascal is internet only.

And Finally sorry to all the forum members, i am here to learn and use pascal, and my intention is not to insult anyone or pascal language.
once again i am really really sorry. please forgive me for my words.


Holiday season is online now. :-)

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Blowfish help
« Reply #20 on: January 09, 2013, 11:47:46 am »
And Finally sorry to all the forum members, i am here to learn and use pascal, and my intention is not to insult anyone or pascal language.
once again i am really really sorry. please forgive me for my words.
No harm done, don't worry  ;)  I even mentioned the bitshift solution in my post in this thread, and i might have showed it too if i could pull it off the top of my head. That is rather advanced knowledge. Even so, i would assume the record solution i mentioned, simple typecast might be faster. But i don't know what it does internally, or what hi(), lo() actually does. We can assume most of the core functions have been optimized to near perfection throughout the years. But then, we know some cases where own solutions can be better.

Blestan

  • Sr. Member
  • ****
  • Posts: 461
Re: Blowfish help
« Reply #21 on: January 09, 2013, 12:10:35 pm »
@deepakk99: It's ok man ...
we will help as mutch as we can .... btw in this moment im just working on a project involving blowfish soi can tell you that that the fastest way to
get xR and xL is to have an array [00..01] of dword as the 64bit data block and use xl:=db[0]; xr:=db[1];
Speak postscript or die!
Translate to pdf and live!

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Blowfish help
« Reply #22 on: January 09, 2013, 12:39:45 pm »
Quote
is this correct for freepascal. If yes, i would request you to suggest the lazarus team to include this is lazarus. It would be nice to have this function.
Your solution doesn't take endianness into consideration (it might be correct on little endian, but wrong on big). Hi() and Lo() do.
Quote
If Pascal is so good as C/C++ then why in any school/universities or colleges there is not an even single subject for pascal.

I know 'C/C++' is tough but, then also 'C' is the mother language. even most robust operating systems are written in  'C\C++' why not in pascal.
You can search the web for this, no need to pour oil into that little fire thrown at you.
« Last Edit: January 09, 2013, 12:47:42 pm by Leledumbo »

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Blowfish help
« Reply #23 on: January 10, 2013, 11:18:30 am »
Quote
is this correct for freepascal. If yes, i would request you to suggest the lazarus team to include this is lazarus. It would be nice to have this function.
Your solution doesn't take endianness into consideration (it might be correct on little endian, but wrong on big). Hi() and Lo() do.
Quote
If Pascal is so good as C/C++ then why in any school/universities or colleges there is not an even single subject for pascal.

I know 'C/C++' is tough but, then also 'C' is the mother language. even most robust operating systems are written in  'C\C++' why not in pascal.
You can search the web for this, no need to pour oil into that little fire thrown at you.


sorry for all.

i am unable to figure out how to implement hi() and lo() in this scenario. Maybe you are right this endianess may cause problem in little or big endian systems.

Holiday season is online now. :-)

 

TinyPortal © 2005-2018