PrePAN

Sign in to PrePAN

Object::Signature::Portable Portable object signatures

Good

Synopsis

    use Object::Signature::Portable;

    $sig = signature( $data ); # MD5 of JSON-encoded $data

    # SHA-1 base-64 for YAML-encoded $data

    use YAML::Syck;

    sub serializer {
      local $YAML::Syck::Headless = 1;
      local $YAML::Syck::SortKeys = 1;
      # ... etc ...
      return Dump($_[0]);
    }

    $sig = signature( digest => 'SHA1', method => 'b64udigest', serializer => \&serializer, data => $data )

Description

This would be largely the same as Object::Signature, except that it will use "canonical" JSON (or perhaps YAML) instead of Storable for serializing the object.

The reason behind this is that Storable does not generate the same format file across different versions of that module on different platforms with different Perl versions. In cases where one needs a "signature" for an object to be shared across multiple platforms, this is a cleaner method for generating signatures.

I am thinking of a way to make the backend (JSON, YAML, or Data::Dumper) an option as well as the signature method (MD5, SHA1, etc.).

Comments

Please sign up to post a review.