Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Gort, klaatu nikto barada." -- The Day the Earth Stood Still


devel / comp.lang.awk / Re: [Complete] Re: djb2 hash using awk

SubjectAuthor
* djb2 hash using awkMichael Sanders
+* Re: djb2 hash using awkJanis Papanagnou
|+- Re: djb2 hash using awkJanis Papanagnou
|+* Re: djb2 hash using awkMichael Sanders
||`- Re: djb2 hash using awkJanis Papanagnou
|`* Re: djb2 hash using awkMichael Sanders
| `* Re: djb2 hash using awkJanis Papanagnou
|  `* Re: djb2 hash using awkManuel Collado
|   `* Re: djb2 hash using awkMichael Sanders
|    `- Re: djb2 hash using awkBen Bacarisse
+* Re: djb2 hash using awkManuel Collado
|`- Re: djb2 hash using awkMichael Sanders
+* Re: djb2 hash using awkBen Bacarisse
|`* Re: djb2 hash using awkMichael Sanders
| +* Re: djb2 hash using awkJanis Papanagnou
| |+* Re: djb2 hash using awkMichael Sanders
| ||`- Re: djb2 hash using awkJanis Papanagnou
| |`- Re: djb2 hash using awkJanis Papanagnou
| `* Re: djb2 hash using awkBen Bacarisse
|  `* Re: djb2 hash using awkMichael Sanders
|   +* Re: djb2 hash using awkJanis Papanagnou
|   |`* Re: djb2 hash using awkKenny McCormack
|   | `- Re: djb2 hash using awkJanis Papanagnou
|   `* Re: djb2 hash using awkBen Bacarisse
|    `* Re: djb2 hash using awkMichael Sanders
|     `* Re: djb2 hash using awkBen Bacarisse
|      `* Re: djb2 hash using awkMichael Sanders
|       `* Re: djb2 hash using awkBen Bacarisse
|        `- Re: djb2 hash using awkMike Sanders
+- Re: djb2 hash using awkMichael Sanders
+- Re: djb2 hash using awkMichael Sanders
`* [Complete] Re: djb2 hash using awkMike Sanders
 `* Re: [Complete] Re: djb2 hash using awkKeith Thompson
  +* Re: [Complete] Re: djb2 hash using awkMike Sanders
  |`* Re: [Complete] Re: djb2 hash using awkKeith Thompson
  | `* Re: [Complete] Re: djb2 hash using awkMike Sanders
  |  `* Re: [Complete] Re: djb2 hash using awkKeith Thompson
  |   `* Re: [Complete] Re: djb2 hash using awkMike Sanders
  |    `- Re: [Complete] Re: djb2 hash using awkMike Sanders
  `* Re: [Complete] Re: djb2 hash using awkJanis Papanagnou
   +- Re: [Complete] Re: djb2 hash using awkMike Sanders
   `- Re: [Complete] Re: djb2 hash using awkMichael Sanders

Pages:12
Re: djb2 hash using awk

<1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1546&group=comp.lang.awk#1546

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a0c:c209:0:b0:65b:323:b8d4 with SMTP id l9-20020a0cc209000000b0065b0323b8d4mr40925qvh.1.1695626819463;
Mon, 25 Sep 2023 00:26:59 -0700 (PDT)
X-Received: by 2002:a05:6870:954e:b0:1dc:34ea:1a6a with SMTP id
v14-20020a056870954e00b001dc34ea1a6amr2982488oal.6.1695626819278; Mon, 25 Sep
2023 00:26:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!45.76.7.193.MISMATCH!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 25 Sep 2023 00:26:58 -0700 (PDT)
In-Reply-To: <87edinghym.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=38.172.116.217; posting-account=aT9GTAoAAABt4sMQrwgB4gcMvkAfx1kx
NNTP-Posting-Host: 38.172.116.217
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<8734z4innl.fsf@bsb.me.uk> <bd073233-0b83-43fc-a415-2fd2f02e7da0n@googlegroups.com>
<87r0mngy2n.fsf@bsb.me.uk> <9f8d5437-e1e5-40bb-bf98-1b9940984cb9n@googlegroups.com>
<87edinghym.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com>
Subject: Re: djb2 hash using awk
From: chrome.tty@gmail.com (Michael Sanders)
Injection-Date: Mon, 25 Sep 2023 07:26:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2256
 by: Michael Sanders - Mon, 25 Sep 2023 07:26 UTC

On Sunday, September 24, 2023 at 8:27:50 PM UTC-5, Ben Bacarisse wrote:

> For example, the DJB hash of the string "abcdef" is 4048079738, but your
> code gives 1900599327. Your hash can go no higher than 2**31 - 2, but
> the original one uses the full range of 32-bit unsigned int.
>
> [...]
>
> This is why halving the range by using only 31 bits is not a good idea.
> It's not a /terrible/ idea because 31 bits is still a huge range, but
> since 32-bit wrapping is free on most hardware, there is absolutely no
> upside to using modulo 2147483647 arithmetic for a hash.
>
> And your saying "32bit - 1 as is the case" means you still don't know
> what the code you wrote is really doing.

Reader's from the future, re-read the 1st paragraph...

Here's where good ol' Ben has (unwittingly, chuckle) proven, & in his own
words mind you, the importance of using of using a unique key number.

Re: djb2 hash using awk

<ba53becf-4e0e-4a55-931c-39fa4c34e35en@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1547&group=comp.lang.awk#1547

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:620a:6746:b0:773:ae7f:ae60 with SMTP id rq6-20020a05620a674600b00773ae7fae60mr51306qkn.12.1695670105300;
Mon, 25 Sep 2023 12:28:25 -0700 (PDT)
X-Received: by 2002:a05:6808:2018:b0:3a7:3737:60fd with SMTP id
q24-20020a056808201800b003a7373760fdmr4438968oiw.7.1695670105069; Mon, 25 Sep
2023 12:28:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 25 Sep 2023 12:28:24 -0700 (PDT)
In-Reply-To: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=38.172.116.217; posting-account=aT9GTAoAAABt4sMQrwgB4gcMvkAfx1kx
NNTP-Posting-Host: 38.172.116.217
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba53becf-4e0e-4a55-931c-39fa4c34e35en@googlegroups.com>
Subject: Re: djb2 hash using awk
From: chrome.tty@gmail.com (Michael Sanders)
Injection-Date: Mon, 25 Sep 2023 19:28:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2215
 by: Michael Sanders - Mon, 25 Sep 2023 19:28 UTC

On Friday, September 22, 2023 at 2:50:10 PM UTC-5, Michael Sanders wrote:

> Greetings folks, just sharing the knowledge (& test posting using google groups).

For the sake of completeness, a key generator (you supply a 32bit key):

# Michael Sanders 2023: key generator for dbj2() & dbj2gawk()
# # creates a key block (25 keys, 5x5 matrix) as shown below:
# # 2147483647 2147483646 2147483645 2147483644 2147483643
# 2147483642 2147483641 2147483640 2147483639 2147483638
# 2147483637 2147483636 2147483635 2147483634 2147483633
# 2147483632 2147483631 2147483630 2147483629 2147483628
# 2147483627 2147483626 2147483625 2147483624 2147483623

BEGIN {

KEYMAX = 2147483647 # your key's max number
BLOCKS = 5 # number of blocks to create

for (x = KEYMAX; x >= 0; x--) {
printf("%010d ", x);
if ((KEYMAX - x) % 5 == 4) {
printf("\n");
if (++y % 5 == 0) {
printf("\n")
if (--BLOCKS < 1) exit
}
}
}

}

Re: djb2 hash using awk

<8734z1hnpa.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1548&group=comp.lang.awk#1548

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.awk
Subject: Re: djb2 hash using awk
Date: Mon, 25 Sep 2023 23:50:41 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <8734z1hnpa.fsf@bsb.me.uk>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<8734z4innl.fsf@bsb.me.uk>
<bd073233-0b83-43fc-a415-2fd2f02e7da0n@googlegroups.com>
<87r0mngy2n.fsf@bsb.me.uk>
<9f8d5437-e1e5-40bb-bf98-1b9940984cb9n@googlegroups.com>
<87edinghym.fsf@bsb.me.uk>
<1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="ec3b8353d514a2991d7d955d9087a71d";
logging-data="2252857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ejjpx9Qwf9rGViK8yZlKWf5S1dDuBb40="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:ZNzV0BT2XT+xGQgqAPs2jBJ1fPo=
sha1:7tph4cgo71wA65cBVAn+oPyBMT0=
X-BSB-Auth: 1.83a9ad0c94650154e717.20230925235041BST.8734z1hnpa.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 25 Sep 2023 22:50 UTC

Michael Sanders <chrome.tty@gmail.com> writes:

> On Sunday, September 24, 2023 at 8:27:50 PM UTC-5, Ben Bacarisse wrote:
>
>> For example, the DJB hash of the string "abcdef" is 4048079738, but your
>> code gives 1900599327. Your hash can go no higher than 2**31 - 2, but
>> the original one uses the full range of 32-bit unsigned int.
>>
>> [...]
>>
>> This is why halving the range by using only 31 bits is not a good idea.
>> It's not a /terrible/ idea because 31 bits is still a huge range, but
>> since 32-bit wrapping is free on most hardware, there is absolutely no
>> upside to using modulo 2147483647 arithmetic for a hash.
>>
>> And your saying "32bit - 1 as is the case" means you still don't know
>> what the code you wrote is really doing.
>
> Reader's from the future, re-read the 1st paragraph...
>
> Here's where good ol' Ben has (unwittingly, chuckle) proven, & in his own
> words mind you, the importance of using of using a unique key number.

What's a key number?

--
Ben.

Re: djb2 hash using awk

<bc8dd27f-f9c9-4161-bfd3-5b05e11ce717n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1549&group=comp.lang.awk#1549

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a0c:ef84:0:b0:65b:13c:63e6 with SMTP id w4-20020a0cef84000000b0065b013c63e6mr43304qvr.6.1695699143324;
Mon, 25 Sep 2023 20:32:23 -0700 (PDT)
X-Received: by 2002:a05:6808:219b:b0:3a3:7087:bbfb with SMTP id
be27-20020a056808219b00b003a37087bbfbmr5058058oib.6.1695699143167; Mon, 25
Sep 2023 20:32:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Mon, 25 Sep 2023 20:32:22 -0700 (PDT)
In-Reply-To: <8734z1hnpa.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=38.172.116.217; posting-account=aT9GTAoAAABt4sMQrwgB4gcMvkAfx1kx
NNTP-Posting-Host: 38.172.116.217
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<8734z4innl.fsf@bsb.me.uk> <bd073233-0b83-43fc-a415-2fd2f02e7da0n@googlegroups.com>
<87r0mngy2n.fsf@bsb.me.uk> <9f8d5437-e1e5-40bb-bf98-1b9940984cb9n@googlegroups.com>
<87edinghym.fsf@bsb.me.uk> <1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com>
<8734z1hnpa.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bc8dd27f-f9c9-4161-bfd3-5b05e11ce717n@googlegroups.com>
Subject: Re: djb2 hash using awk
From: chrome.tty@gmail.com (Michael Sanders)
Injection-Date: Tue, 26 Sep 2023 03:32:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 20
 by: Michael Sanders - Tue, 26 Sep 2023 03:32 UTC

On Monday, September 25, 2023 at 5:50:45 PM UTC-5, Ben Bacarisse wrote:

> What's a key number?

It doesn't matter Ben. I do appreciate your
willingness to help despite our p*ssing contest.
Moving forward, here's an intended usage example.

Given a CSV file of: Smith, John, HASH

And parsed as, oh something like:

if ($1 == "Smith" && $2 == "John") {

if ($3 == dbj2("policy_number")) {...}
}

We've gained simple a way to obfuscate small chucks
of patient records.

Re: djb2 hash using awk

<87wmwdfafi.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1550&group=comp.lang.awk#1550

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.awk
Subject: Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 12:20:17 +0100
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <87wmwdfafi.fsf@bsb.me.uk>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<8734z4innl.fsf@bsb.me.uk>
<bd073233-0b83-43fc-a415-2fd2f02e7da0n@googlegroups.com>
<87r0mngy2n.fsf@bsb.me.uk>
<9f8d5437-e1e5-40bb-bf98-1b9940984cb9n@googlegroups.com>
<87edinghym.fsf@bsb.me.uk>
<1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com>
<8734z1hnpa.fsf@bsb.me.uk>
<bc8dd27f-f9c9-4161-bfd3-5b05e11ce717n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="ec3b8353d514a2991d7d955d9087a71d";
logging-data="2613531"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19WlH4+r8xDx2sydrHcbVvlxAf9AF+Ttcg="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:u7L6z3atJ81tL1pTsYMZqz3hSaw=
sha1:yhsmsWq1oFZhuiy/MZ73+x0hftI=
X-BSB-Auth: 1.1796ff37d2b73e436ef3.20230926122017BST.87wmwdfafi.fsf@bsb.me.uk
 by: Ben Bacarisse - Tue, 26 Sep 2023 11:20 UTC

Michael Sanders <chrome.tty@gmail.com> writes:

> On Monday, September 25, 2023 at 5:50:45 PM UTC-5, Ben Bacarisse wrote:
>
>> What's a key number?
>
> It doesn't matter Ben.

OK. I thought you might want to be understood.

--
Ben.

[Complete] Re: djb2 hash using awk

<uevad2$2l02b$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1551&group=comp.lang.awk#1551

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 19:11:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 139
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uevad2$2l02b$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
Injection-Date: Tue, 26 Sep 2023 19:11:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6ffe3db24c02060decc74ee8b3f370a5";
logging-data="2785355"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ikGn4xRaXJa1W7jGKRElv"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:bikOwkfB8lcFb6dQAc/BrRpOqmU=
 by: Mike Sanders - Tue, 26 Sep 2023 19:11 UTC

Well, about to bring this little project to its conclusion =)
A special thanks (in no particular order) to:

Janis Papanagnou, Manuel Collado, & Ben Bacarisse.

Great insights, advice & help, appreciate you all.

tags: awk, sh, djb2, hash, keys, crypto

# Michael Sanders 2023: djb2 - simple string hash for awk
# # https://porkchop.neocities.org/notes/djb2.txt
# # usage example...
# # given a CSV file of: Smith, John, HASH
# # you could deploy djb2() in the following manner:
# # if ($1 == "Smith" && $2 == "John" && $3 == djb2("medical_condition")) {...}
# # if a unique number is desired, use one of the key generators below

function djb2(str, hash, x, y, ascii) {

hash = 5381
y = length(str)

for(x = 1; x <= y; x++) {
ascii = substr(str, x, 1)
hash = (hash * 33 + alphanum(ascii)) % ((2^32) - 1) # 32-bit key or
# hash = (hash * 33 + alphanum(ascii)) % 2147483647 # generated key
}

return hash

}

function alphanum(tmp) {

return index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", tmp)

}

BEGIN {

print djb2("sensitive data")

}

# -----------------------------------------------------------------

# Michael Sanders 2023: key generator for djb2.awk
# # creates 1250 random & unique keys, where each block
# contains 25 keys within a 5x5 matrix, sample output:
# # 4044119583 2096446957 0146530746 2307162583 1145196028
# 2074570158 0782926302 0126577871 1957612719 1264962473
# 2768662034 3770197738 1165669763 3328823363 1160752685
# 1609089706 2699782284 0621370497 3966710650 2024400675
# 1453519246 1174954443 1588003602 3567230071 2877329117

BEGIN {

MIN = 0123456789 # min 10 digit num
MAX = 4294967295 # max 10 digit num
BLX = 50 # number of blocks

seed = systime(); srand(seed)
printf("\nSeed: %s\n\n", seed)

for (x = 1; x <= BLX; x++) {
for (y = 1; y <= 5; y++) {
s = ""
for (z = 1; z <= 5; z++) {
do {key = int(rand() * (MAX - MIN + 1)) + MIN} while(key in keys)
keys[key]
s = (s == "" ? sprintf("%010d", key) : s " " sprintf("%010d", key))
}
printf("%s\n", s)
}
if (x < BLX) printf("%s", "\n")
}
}

# -----------------------------------------------------------------

# Michael Sanders 2023: key generator2 for older awks using dbj2.awk
# # use this key generator instead if your awk lacks the abilty to
# use either large integers or the systime() builtin
# # creates key blocks (25 keys, 5x5 matrix) as shown below:
# # 2147483647 2147483646 2147483645 2147483644 2147483643
# 2147483642 2147483641 2147483640 2147483639 2147483638
# 2147483637 2147483636 2147483635 2147483634 2147483633
# 2147483632 2147483631 2147483630 2147483629 2147483628
# 2147483627 2147483626 2147483625 2147483624 2147483623

BEGIN {

KEYMAX = 2147483647 # your 10 digit max number
BLOCKS = 50 # number of blocks to create

for (x = KEYMAX; x >= 0; x--) {
printf("%010d ", x);
if ((KEYMAX - x) % 5 == 4) {
printf("\n");
if (++y % 5 == 0) {
printf("\n")
if (--BLOCKS < 1) exit
}
}
}

}

# -----------------------------------------------------------------

notes:

https://stackoverflow.com/questions/1579721/why-are-5381-and-33-so-important-in-the-djb2-algorithm

https://stackoverflow.com/questions/10696223/reason-for-the-number-5381-in-the-djb-hash-function

https://groups.google.com/g/comp.lang.c/c/lSKWXiuNOAk

https://en.wikipedia.org/wiki/Daniel_J._Bernstein

https://groups.google.com/g/comp.lang.awk/c/FZNpn8Sxf9k

# eof

--
:wq
Mike Sanders

Re: djb2 hash using awk

<uevavf$2l4gj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1552&group=comp.lang.awk#1552

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 19:21:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uevavf$2l4gj$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <8734z4innl.fsf@bsb.me.uk> <bd073233-0b83-43fc-a415-2fd2f02e7da0n@googlegroups.com> <87r0mngy2n.fsf@bsb.me.uk> <9f8d5437-e1e5-40bb-bf98-1b9940984cb9n@googlegroups.com> <87edinghym.fsf@bsb.me.uk> <1610aba1-bf05-4827-bb69-d6dd5837786bn@googlegroups.com> <8734z1hnpa.fsf@bsb.me.uk> <bc8dd27f-f9c9-4161-bfd3-5b05e11ce717n@googlegroups.com> <87wmwdfafi.fsf@bsb.me.uk>
Injection-Date: Tue, 26 Sep 2023 19:21:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6ffe3db24c02060decc74ee8b3f370a5";
logging-data="2789907"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18f4o0Y5Wn1LHHk1C1kMlJs"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:zoJvHh/I3KJsbOufxjm9LQxKyiM=
 by: Mike Sanders - Tue, 26 Sep 2023 19:21 UTC

Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:

> OK. I thought you might want to be understood.

Well, I wake up in a new world everyday it seems =)

Have look up thread somewhere or another (subject
contains '[Complete]'.

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<87bkdotydf.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1553&group=comp.lang.awk#1553

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 14:31:40 -0700
Organization: None to speak of
Lines: 58
Message-ID: <87bkdotydf.fsf@nosuchdomain.example.com>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<uevad2$2l02b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ec8cfd24bb03823b1c68ea0c43111c0c";
logging-data="2819685"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WWsb5fT3XgiDssXjGc9ja"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:/dwtTSDgv39R2zj7iQVD8I8yru0=
sha1:mvH8l9+/uHSNEDBEgZ0LtnVCgXg=
 by: Keith Thompson - Tue, 26 Sep 2023 21:31 UTC

porkchop@invalid.foo (Mike Sanders) writes:
[...]
> function djb2(str, hash, x, y, ascii) {
>
> hash = 5381
> y = length(str)
>
> for(x = 1; x <= y; x++) {
> ascii = substr(str, x, 1)
> hash = (hash * 33 + alphanum(ascii)) % ((2^32) - 1) # 32-bit key or
> # hash = (hash * 33 + alphanum(ascii)) % 2147483647 # generated key
> }
>
> return hash
>
> }
>
> function alphanum(tmp) {
>
> return index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", tmp)
>
> }
[...]

Why do you call this "djb2"?

Here's a description of the djb2 hash function from
<https://www.eecs.yorku.ca/~oz/hash.html>:

this algorithm (k=33) was first reported by dan bernstein many years
ago in comp.lang.c. another version of this algorithm (now favored
by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the
magic of number 33 (why it works better than many other constants,
prime or not) has never been adequately explained.

unsigned long
hash(unsigned char *str)
{
unsigned long hash = 5381;
int c;

while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;
}

I see some similarities between the original djb and your hash function,
and yours was undoubtedly inspired by djb2, but they're very much not the
same thing. Would you agree that calling it "djb2" is misleading?

I find it odd that your function treats all non-alphanumeric characters
as the same. Is there a reason for that?

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: [Complete] Re: djb2 hash using awk

<uevlg7$2n4as$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1554&group=comp.lang.awk#1554

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 22:20:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 67
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uevlg7$2n4as$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com>
Injection-Date: Tue, 26 Sep 2023 22:20:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7c0002442be579e31fa78b63894e032e";
logging-data="2855260"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193cV0zGmx7iX5UaUzpfyfN"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:ElLEOer5HPZVF8fnjXJXZ3RMUxM=
 by: Mike Sanders - Tue, 26 Sep 2023 22:20 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Why do you call this "djb2"?

Well, because that is what its called.

> Here's a description of the djb2 hash function from
> <https://www.eecs.yorku.ca/~oz/hash.html>:

Yes, one of the links in the notes section has a reference to that url.
Did you not read the notes?

> this algorithm (k=33) was first reported by dan bernstein many years
> ago in comp.lang.c. another version of this algorithm (now favored
> by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the
> magic of number 33 (why it works better than many other constants,
> prime or not) has never been adequately explained.

I know, intesting stuff I thought!
> unsigned long
> hash(unsigned char *str)
> {
> unsigned long hash = 5381;
> int c;
>
> while (c = *str++)
> hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
>
> return hash;
> }

Here's my take in virtually indentical take in c (uint32_t):

uint32_t djb2(const char *str) {

uint32_t hash = 5381;
int c;
while ((c = *str++))
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

return hash;
}
> I see some similarities between the original djb and your hash function,
> and yours was undoubtedly inspired by djb2, but they're very much not the
> same thing. Would you agree that calling it "djb2" is misleading?

Nope, wont change it either. =) I've provided my notes, so others can study it,
use it, extend it, trace it back to its source if so compelled... I make
no claims as to being its originator. Heck the *cough* notes *cough* alone
demonstrate that. I feel its 'nifty' for no reason than its short & sweet.
awk (or least I) needed this functionality. Besides, I'm hard-pressed to think
anyone will mistake it as anything misleading. I reckon no good deed will
go unpunished. Such is life on usenet...

> I find it odd that your function treats all non-alphanumeric characters
> as the same. Is there a reason for that?

Yes, just dealing (a-z, A-Z, 0-9) here. Personally don't want to imbue
it with extra, uneeded baggage. Feel free to modify it to suit your tastes.

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<877coctv9k.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1555&group=comp.lang.awk#1555

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 15:38:47 -0700
Organization: None to speak of
Lines: 35
Message-ID: <877coctv9k.fsf@nosuchdomain.example.com>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<uevad2$2l02b$1@dont-email.me>
<87bkdotydf.fsf@nosuchdomain.example.com>
<uevlg7$2n4as$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="08e30d084ec8438dcadf9cbd76f2c53f";
logging-data="2858099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sa7stc7iYxOmxBR9EVAUh"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:zD6Pdkf9uGeK1p52310lrXNH1S8=
sha1:ooDtRfGfpDULlMeFO3l8kPgTCi8=
 by: Keith Thompson - Tue, 26 Sep 2023 22:38 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Why do you call this "djb2"?
>
> Well, because that is what its called.

You mean that's what you decided to call it. I'm asking why.

>> Here's a description of the djb2 hash function from
>> <https://www.eecs.yorku.ca/~oz/hash.html>:
>
> Yes, one of the links in the notes section has a reference to that url.
> Did you not read the notes?

I did. That's how I noticed that you've implemented a different
algorithm than any version of the original djb2.

[...]

>> I see some similarities between the original djb and your hash function,
>> and yours was undoubtedly inspired by djb2, but they're very much not the
>> same thing. Would you agree that calling it "djb2" is misleading?
>
> Nope, wont change it either. =)
[...]

Noted.

What you've posted is not djb2. You shouldn't claim that it is. You've
made it clear that you intend to continue to do so.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: [Complete] Re: djb2 hash using awk

<uevogb$2ngiq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1556&group=comp.lang.awk#1556

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 23:12:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uevogb$2ngiq$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com> <uevlg7$2n4as$1@dont-email.me> <877coctv9k.fsf@nosuchdomain.example.com>
Injection-Date: Tue, 26 Sep 2023 23:12:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7c0002442be579e31fa78b63894e032e";
logging-data="2867802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qbc4tdu6sbm2A3UEU7hGV"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:+h4HPqEuDth4OGON6y2zsQqPc8I=
 by: Mike Sanders - Tue, 26 Sep 2023 23:12 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> You mean that's what you decided to call it. I'm asking why.

Well, I don't think I have an anwser that will satisfy you.
> What you've posted is not djb2. You shouldn't claim that it is. You've
> made it clear that you intend to continue to do so.

What do you feel I ought to do to clarify the problem with this cavet:

It wont be taken down or renamed.

Perhaps add clarification to the document how my take only deals with
alphanumeric chars? Let's work it out.

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<8734z0trsq.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1557&group=comp.lang.awk#1557

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Tue, 26 Sep 2023 16:53:41 -0700
Organization: None to speak of
Lines: 32
Message-ID: <8734z0trsq.fsf@nosuchdomain.example.com>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<uevad2$2l02b$1@dont-email.me>
<87bkdotydf.fsf@nosuchdomain.example.com>
<uevlg7$2n4as$1@dont-email.me>
<877coctv9k.fsf@nosuchdomain.example.com>
<uevogb$2ngiq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="08e30d084ec8438dcadf9cbd76f2c53f";
logging-data="2882985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ATaDdlkD213ggY3TaCgG0"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:2ymuefKbPIV6+ijfrnOa2W35uFs=
sha1:q9hCpYvl5u04/uA+Ve+qLsQmho4=
 by: Keith Thompson - Tue, 26 Sep 2023 23:53 UTC

porkchop@invalid.foo (Mike Sanders) writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> You mean that's what you decided to call it. I'm asking why.
>
> Well, I don't think I have an anwser that will satisfy you.

Then post an answer that doesn't satisfy me. So far you've said nothing.

>> What you've posted is not djb2. You shouldn't claim that it is. You've
>> made it clear that you intend to continue to do so.
>
> What do you feel I ought to do to clarify the problem

Rename it.

> with this cavet:
> It wont be taken down or renamed.

If you wrote a hash function that yields a 160-bit result that differs
from the result returned by the actual sha1 function, would you release
it under the name "sha1"? Assuming your answer is no, how is this
different? (Admittedly djb2 isn't as well established.)

> Perhaps add clarification to the document how my take only deals with
> alphanumeric chars? Let's work it out.

Work it out yourself.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: [Complete] Re: djb2 hash using awk

<uevu6a$2ogat$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1558&group=comp.lang.awk#1558

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Wed, 27 Sep 2023 00:49:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uevu6a$2ogat$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com> <uevlg7$2n4as$1@dont-email.me> <877coctv9k.fsf@nosuchdomain.example.com> <uevogb$2ngiq$1@dont-email.me> <8734z0trsq.fsf@nosuchdomain.example.com>
Injection-Date: Wed, 27 Sep 2023 00:49:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7c0002442be579e31fa78b63894e032e";
logging-data="2900317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Gfen6Rbdjf7ZuFMbASA2y"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:eV7WZFlLTXuXdP+e1013h4dI/G8=
 by: Mike Sanders - Wed, 27 Sep 2023 00:49 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Work it out yourself.

Will do.

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<uf00ml$2osh0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1559&group=comp.lang.awk#1559

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Wed, 27 Sep 2023 01:32:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uf00ml$2osh0$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com> <uevlg7$2n4as$1@dont-email.me> <877coctv9k.fsf@nosuchdomain.example.com> <uevogb$2ngiq$1@dont-email.me> <8734z0trsq.fsf@nosuchdomain.example.com> <uevu6a$2ogat$1@dont-email.me>
Injection-Date: Wed, 27 Sep 2023 01:32:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7c0002442be579e31fa78b63894e032e";
logging-data="2912800"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9J0CYqJDoQJ9Bo4OBV+8D"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:aQ+7hTFgPRYk36hAgNxtiMR0Ke4=
 by: Mike Sanders - Wed, 27 Sep 2023 01:32 UTC

Mike Sanders <porkchop@invalid.foo> wrote:

> Will do.

https://porkchop.neocities.org/notes/mHash.txt

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<uf0nlg$306o2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1562&group=comp.lang.awk#1562

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Wed, 27 Sep 2023 10:03:59 +0200
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uf0nlg$306o2$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 08:04:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="68dbff0f845fd0821cc4f86884ca0699";
logging-data="3152642"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QL45jPcldOjGkCIV9y2g7"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:IyaDazETFHdtc0zKpYHPM6SgWps=
In-Reply-To: <87bkdotydf.fsf@nosuchdomain.example.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Wed, 27 Sep 2023 08:03 UTC

On 26.09.2023 23:31, Keith Thompson wrote:
> porkchop@invalid.foo (Mike Sanders) writes:
> [...]
>
> Why do you call this "djb2"?
>
> Here's a description of the djb2 hash function from
> <https://www.eecs.yorku.ca/~oz/hash.html>:
> [...]
>
> I see some similarities between the original djb and your hash function,
> and yours was undoubtedly inspired by djb2, but they're very much not the
> same thing. Would you agree that calling it "djb2" is misleading?
>
> I find it odd that your function treats all non-alphanumeric characters
> as the same. Is there a reason for that?
>

Indeed. I as well was misleaded by the impression I've got that he
was trying to implement (just in a wrong way) an existing algorithm.
I noticed that (my) mistake not before I saw two versions of his code
in one post, each using different character set encodings - which of
course would lead to different results even if we compare only the
OP's own implementations' results. This arbitrariness in conjunction
with the inherent flaws the code versions had (and may still have;
I don't bother any more) makes clear that we obviously have a "Not
Invented Here" case (https://en.wikipedia.org/wiki/Not_invented_here),
which most likely makes all in depth discussions void anyway. Glad
it became obvious after all. (Bad that I noticed that too late. And I
see that the OP just recently followed your suggestion to rename his
hash function.)

It's always good to get information about the _intention_ of a piece
of posted code early and with the original post; that way bandworm
threads and misunderstandings could be avoided.

<OT>
Let's come back to the actual application and application domain ...

Inferred from the OP's posting where he wrote: dbj2("policy_number"))
and "simple a way to obfuscate small chucks of patient records." ...

In statistical medicine context there's demand to anonymize patient
data. For statistical purposes and cause-effect insights it's usually
necessary to be able to assign data to an "individual entity" without
disclosing his identity. But a hash code does not support that; it
can lead to "ID"-clashes that assigns different results to one same
subject. You need to create (real) keys. - Remember Ben's confusion
about (the OP's misnomer) "key number"! The OP may seem to require
keys but he's creating a hash value.

Of course if a hash value is sufficient - only the OP knows this! -
then I'd have used some existing and proven algorithm instead of
inventing my own (with possible flaws or non-obvious bad properties).
(But this as well has the OP to decide and is not an Awk question
anyway.)
</OT>

Janis

Re: [Complete] Re: djb2 hash using awk

<uf113t$31ngp$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1564&group=comp.lang.awk#1564

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: porkchop@invalid.foo (Mike Sanders)
Newsgroups: comp.lang.awk
Subject: Re: [Complete] Re: djb2 hash using awk
Date: Wed, 27 Sep 2023 10:45:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Sender: Mike Sanders <busybox@sdf.org>
Message-ID: <uf113t$31ngp$1@dont-email.me>
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com> <uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com> <uf0nlg$306o2$1@dont-email.me>
Injection-Date: Wed, 27 Sep 2023 10:45:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6fe25f3b75fac0b902b81cc965bfc872";
logging-data="3202585"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jyETeFFcIutNP+W+6Lbh/"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (NetBSD/9.3 (amd64))
Cancel-Lock: sha1:BlG9epWSnr1Db0INMo0YVXhp7fA=
 by: Mike Sanders - Wed, 27 Sep 2023 10:45 UTC

Wow... I've simply attempted to learn & share that with others.
I cant recall every seeing such, I dunno, at a loss for words.
It would've taken me a few more iterations to bring it all togther
but with this environment, its not okay.

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> Indeed. I as well was misleaded by the impression I've got that he
> was trying to implement (just in a wrong way) an existing algorithm.
> I noticed that (my) mistake not before I saw two versions of his code
> in one post, each using different character set encodings - which of
> course would lead to different results even if we compare only the
> OP's own implementations' results. This arbitrariness in conjunction
> with the inherent flaws the code versions had (and may still have;
> I don't bother any more) makes clear that we obviously have a "Not
> Invented Here" case (https://en.wikipedia.org/wiki/Not_invented_here),
> which most likely makes all in depth discussions void anyway. Glad
> it became obvious after all. (Bad that I noticed that too late. And I
> see that the OP just recently followed your suggestion to rename his
> hash function.)
>
> It's always good to get information about the _intention_ of a piece
> of posted code early and with the original post; that way bandworm
> threads and misunderstandings could be avoided.
>
> <OT>
> Let's come back to the actual application and application domain ...
>
> Inferred from the OP's posting where he wrote: dbj2("policy_number"))
> and "simple a way to obfuscate small chucks of patient records." ...
>
> In statistical medicine context there's demand to anonymize patient
> data. For statistical purposes and cause-effect insights it's usually
> necessary to be able to assign data to an "individual entity" without
> disclosing his identity. But a hash code does not support that; it
> can lead to "ID"-clashes that assigns different results to one same
> subject. You need to create (real) keys. - Remember Ben's confusion
> about (the OP's misnomer) "key number"! The OP may seem to require
> keys but he's creating a hash value.
>
> Of course if a hash value is sufficient - only the OP knows this! -
> then I'd have used some existing and proven algorithm instead of
> inventing my own (with possible flaws or non-obvious bad properties).
> (But this as well has the OP to decide and is not an Awk question
> anyway.)
> </OT>
>
> Janis
>

--
:wq
Mike Sanders

Re: [Complete] Re: djb2 hash using awk

<517e4d73-9944-404c-97a1-dfc0a8ace764n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1565&group=comp.lang.awk#1565

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:622a:11c4:b0:412:2107:7f1d with SMTP id n4-20020a05622a11c400b0041221077f1dmr35035qtk.7.1695838402449;
Wed, 27 Sep 2023 11:13:22 -0700 (PDT)
X-Received: by 2002:a05:6808:2107:b0:3ae:532c:e93a with SMTP id
r7-20020a056808210700b003ae532ce93amr1301072oiw.11.1695838402116; Wed, 27 Sep
2023 11:13:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Wed, 27 Sep 2023 11:13:21 -0700 (PDT)
In-Reply-To: <uf0nlg$306o2$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=38.172.116.217; posting-account=aT9GTAoAAABt4sMQrwgB4gcMvkAfx1kx
NNTP-Posting-Host: 38.172.116.217
References: <69a6c6d6-624b-47a9-8119-873dffdcb161n@googlegroups.com>
<uevad2$2l02b$1@dont-email.me> <87bkdotydf.fsf@nosuchdomain.example.com> <uf0nlg$306o2$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <517e4d73-9944-404c-97a1-dfc0a8ace764n@googlegroups.com>
Subject: Re: [Complete] Re: djb2 hash using awk
From: chrome.tty@gmail.com (Michael Sanders)
Injection-Date: Wed, 27 Sep 2023 18:13:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 8
 by: Michael Sanders - Wed, 27 Sep 2023 18:13 UTC

On Wednesday, September 27, 2023 at 3:04:03 AM UTC-5, Janis Papanagnou wrote:

> Of course if a hash value is sufficient - only the OP knows this!

key = 32bitmax - random_lesser

(admin issues keys so no duplicates)

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor