Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Oops... 2013/3/24 silvioprog > [...] > Result: 0b7252985d63555b31db4755f37efe218c509711 (same result in PHP, JS > and Phyton! ;) ) > ... Result *in my PC*: 0b7252985d63555b31db4755f37efe218c509711 -- Silvio Clécio My public projects - github.com/silvioprog

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Eureka! After spending all day working on it, I finally did it! The pseudo steps are here: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code And, this is the final code (please improves it please): uses SHA1; function SHA1Raw(const ABuffer; const ABufferLength: PtrUInt): str

Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-23 Thread Xiangrong Fang
I think the problem is not fixed in 2.7.1: xrfang@laptop ~/fpc $ ./compiler/ppcx64 -n -Furtl/units/x86_64-linux -Fupackages/fcl-base/units/x86_64-linux -viwn -FE/home/xrfang -Sc demo2.lpr Target OS: Linux for x86-64 Compiling demo2.lpr Compiling treap.pas demo2.lpr(88,11) Error: Incompatible types

[fpc-pascal] Re: OOP in FreePascal ARM-Embedded

2013-03-23 Thread Juan Duran
Graeme Geldenhuys writes: > > On 2013-02-27 08:28, Juan Duran wrote: > > Is anybody working on being able to uses classes, methods, etc (OOP) in > > freepascal compiler for ARM embedded platform? > > OOP works fine already on that platform... what specific are you looking > for? > > Regards, >

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tomas Hajny
On Sat, March 23, 2013 16:21, silvioprog wrote: > 2013/3/23 Tomas Hajny >> On Sat, March 23, 2013 06:28, silvioprog wrote: >> >> Hi, >> >> > How to get HMAC_SHA1 using native functions of FPC? >> > >> > HMAC_SHA1: >> > >> http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 David Butler > What do you mean by "native"? > > It is pure pascal code that compiles under Delphi and FreePascal. > > Using it is as easy as: > > SHA1DigestToHexA(CalcHMAC_SHA1('secret', 'message') > To not implement a big code like this: unit Unit1; {$mode objfpc}{$H+} interface

Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-23 Thread Sven Barth
On 23.03.2013 14:51, Xiangrong Fang wrote: I got this error now: treap.pas(311,48) Error: Illegal expression treap.pas(311,50) Error: Illegal expression treap.pas(311,50) Fatal: Syntax error, ";" expected but "ordinal const" found Fatal: Compilation aborted The line that generated this error is

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread David Butler
What do you mean by "native"? It is pure pascal code that compiles under Delphi and FreePascal. Using it is as easy as: SHA1DigestToHexA(CalcHMAC_SHA1('secret', 'message') On Sat, Mar 23, 2013 at 5:18 PM, silvioprog wrote: > 2013/3/23 David Butler > >> Hi >> >> You can find a hash library th

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Other PHP function: $block_size) { $k = pack("H*", sha1($key)); } else { $k = str_pad($key, $block_Size, "\x00", STR_PAD_RIGHT); } $ki = ''; for($i = 0; $i < $block_size; $i++) { $ki .= chr(ord(substr($k, $i, 1)) ^ 0x36); } $ko = ''; for($i = 0; $i < $block_size; $i++) { $ko .= chr(ord(substr

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
Hello, I could be wrong, but I think that Synapse function have a bug. See: Using PHP: Result: b8e7ae12510bdfb1812e463a7f086122cf37e4f7 Using the http://www.freeformatter.com site Result: 5d4db2701c7b07de0e23db3e4f22e88bc1a31a49 Using Synapse: uses synacode; begin Write(HMAC_SHA1('The quic

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tony Whyman > Silvio, > > Just one extra point - the snippet I sent is example code. It is not > intended to be RFC compliant. > > Regards > > Tony Whyman > MWA > Thank you friend for the answer! So, seems the Synapse library has the function I'm looking for. I'll compare it with PHP

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tony Whyman
Silvio, Just one extra point - the snippet I sent is example code. It is not intended to be RFC compliant. Regards Tony Whyman MWA On 23/03/13 15:24, silvioprog wrote: > 2013/3/23 Tony Whyman > > > Silvio, > > I had the same requirement for an HMA

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tony Whyman > Silvio, > > I had the same requirement for an HMAC and used the DCP library: > > http://wiki.freepascal.org/DCPcrypt > > I then used the following code snippet to generate the HMAC > > Regards > > Tony Whyman > MWA > > unit hmac; > > {$mode objfpc}{$H+} > > interface > >

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 Tomas Hajny > On Sat, March 23, 2013 06:28, silvioprog wrote: > > Hi, > > > How to get HMAC_SHA1 using native functions of FPC? > > > > HMAC_SHA1: > > > http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29 > > Doesn't package h

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread silvioprog
2013/3/23 David Butler > Hi > > You can find a hash library that supports HMAC-SHA1 here: > > http://fundementals.sourceforge.net/dl.html > But it's not native in Free Pascal. x( -- Silvio Clécio My public projects - github.com/silvioprog ___ fpc-pasc

Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-23 Thread Xiangrong Fang
I got this error now: treap.pas(311,48) Error: Illegal expression treap.pas(311,50) Error: Illegal expression treap.pas(311,50) Fatal: Syntax error, ";" expected but "ordinal const" found Fatal: Compilation aborted The line that generated this error is: if Result = NullNode then begin if (

Re: [fpc-pascal] Re: Use generic class as parameter (was: how to write enumerator for trees)

2013-03-23 Thread Sven Barth
On 23.03.2013 03:35, Xiangrong Fang wrote: Hi Sven, My unite uses contnrs unit, how can I instruct the compiler to use the contnrs unit (also the Classes and sysutils units) of v2.7.1? I have already built 2.7.1 and now try to compile my program in the fpc source dir as you told. The Classes

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tony Whyman
Silvio, I had the same requirement for an HMAC and used the DCP library: http://wiki.freepascal.org/DCPcrypt I then used the following code snippet to generate the HMAC Regards Tony Whyman MWA unit hmac; {$mode objfpc}{$H+} interface uses Classes, SysUtils; procedure MakeHMAC(text: stri

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread Tomas Hajny
On Sat, March 23, 2013 06:28, silvioprog wrote: Hi, > How to get HMAC_SHA1 using native functions of FPC? > > HMAC_SHA1: > http://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples_of_HMAC_.28MD5.2C_SHA1.2C_SHA256.29 Doesn't package hash (included with FPC by default for all

Re: [fpc-pascal] Re: Example: regular expressions and "hash-tables"

2013-03-23 Thread Mark Morgan Lloyd
Mattias Gaertner wrote: Also, there doesn't seem to be much use of regular expressions. Well, I guess Pascal programmers prefer readability over shortness. They're definitely not a panacea, but where you want to do things like extract the x.y.z version number from e.g 'PostgreSQL 8.4.6 on

Re: [fpc-pascal] HMAC_SHA1 and FPC

2013-03-23 Thread David Butler
Hi You can find a hash library that supports HMAC-SHA1 here: http://fundementals.sourceforge.net/dl.html On Sat, Mar 23, 2013 at 7:28 AM, silvioprog wrote: > Hello, > > How to get HMAC_SHA1 using native functions of FPC? > > HMAC_SHA1: > http://en.wikipedia.org/wiki/Hash-based_message_authent