Header: christian-rossow.de
Apply for a PhD/PostDoc position in my System Security research group at Saarland University.


If you can't explain it simply, you don't understand it well enough.

Report - pg-randomness released on pgFoundry

Today I released the project pg-randomness on pgFoundry. This project provides C language functions to PostgreSQL that support some statistical calculations to determine the randomness of data (in the bytea format), such as:
  • bit_entropy(bytea): return Shannon bit entropy
  • byte_entropy(bytea): return Shannon byte entropy
  • bit_entropy(bytea): return Pearson's chi-square statistics

Any feedback is welcome!

By the way: There is a quick solution in case you need to concatenate many bytea values using an aggregate function. For example, suppose you would like to calculate the entropy of a all bytea values in your table concatenated. Note that this cannot be done by simply calculating the entropy value-wise and using the average entropy as total entropy. What you'd like to do is something like the following:

SELECT byte_entropy(bytea_concat(my_data)) GROUP BY xyz;

Since there is no bytea_concat aggregate function per se, define it first using the following statement:

bytea x := bytea_concat(bytea) aggregation function
CREATE AGGREGATE bytea_concat (bytea)
    sfunc = byteacat,
    stype = bytea,
    initcond = ''