diff options
author | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2014-03-28 14:09:52 +0000 |
---|---|---|
committer | svenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2014-03-28 14:09:52 +0000 |
commit | 8478764c9782f302d1dc427e93e5757bfdfad704 (patch) | |
tree | 732bb723ddf84f1f5d77a3c9ae518289bbdb80d2 /packages/hash/examples | |
parent | a2705006fbd6aee7c3d3015e6e530ce41ad2c791 (diff) | |
download | fpc-8478764c9782f302d1dc427e93e5757bfdfad704.tar.gz |
Add implementation of HMAC-MD5 and HMAC-SHA1 from Silvio Clecio. Resolves Mantis #24136
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@27319 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/hash/examples')
-rw-r--r-- | packages/hash/examples/hmd5.pp | 15 | ||||
-rw-r--r-- | packages/hash/examples/hsha1.pp | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/packages/hash/examples/hmd5.pp b/packages/hash/examples/hmd5.pp new file mode 100644 index 0000000000..5c0cc31d3f --- /dev/null +++ b/packages/hash/examples/hmd5.pp @@ -0,0 +1,15 @@ +// See some samples in: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code +program hmd5; + +{$mode objfpc}{$H+} + +uses + HMAC; + +begin + // for HMAC_MD5("", "") = 0x74e6f7298a9c2d168935f58c001bad88 + WriteLn('Example 1: ', HMACMD5Print(HMACMD5Digest('', ''))); + // for HMAC_MD5("key", "The quick brown fox jumps over the lazy dog") = 0x80070713463e7749b90c2dc24911e275 + WriteLn('Example 2: ', HMACMD5('key', 'The quick brown fox jumps over the lazy dog')); +end. + diff --git a/packages/hash/examples/hsha1.pp b/packages/hash/examples/hsha1.pp new file mode 100644 index 0000000000..5a79c53c1e --- /dev/null +++ b/packages/hash/examples/hsha1.pp @@ -0,0 +1,15 @@ +// See some samples in: http://en.wikipedia.org/wiki/Hash-based_message_authentication_code +program hsha1; + +{$mode objfpc}{$H+} + +uses + HMAC; + +begin + // for HMAC_SHA1("", "") = 0xfbdb1d1b18aa6c08324b7d64b71fb76370690e1d + WriteLn('Example 1: ', HMACSHA1Print(HMACSHA1Digest('', ''))); + // for HMAC_SHA1("key", "The quick brown fox jumps over the lazy dog") = 0xde7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9 + WriteLn('Example 2: ', HMACSHA1('key', 'The quick brown fox jumps over the lazy dog')); +end. + |