--- Begin Message ---
>>Yes, we don't need much to get enough collision-resistance. Just
>>wanted
>>to make sure and check it explicitly.


I have done some test with sha1, with base62 encode  ('0..9', 'A..Z',
'a..z)


the node-name require to start with an alpha character prefix


encodebase62(sha1("$volid-$snapid") : 5zU4nVxN7gIUWMaskKc4y6EawWu

28characters

so we have space to prefix like for example:

f-5zU4nVxN7gIUWMaskKc4y6EawWu  for fmt-node  
e-5zU4nVxN7gIUWMaskKc4y6EawWu  for file-node




sub encode_base62 {
    my ($input) = @_;
    my @chars = ('0'..'9', 'A'..'Z', 'a'..'z');
    my $base = 62;
    my $value = 0;

    foreach my $byte (unpack('C*', $input)) {
        $value = $value * 256 + $byte;
    }

    my $result = '';
    while ($value > 0) {
        $result = $chars[$value % $base] . $result;
        $value = int($value / $base);
    }

    return $result || '0';
}


--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to