downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Imagick::getImageSize> <Imagick::getImageScene
[edit] Last updated: Fri, 25 May 2012

view this page in

Imagick::getImageSignature

(PECL imagick 2.0.0)

Imagick::getImageSignatureGénère une signature SHA-256

Description

string Imagick::getImageSignature ( void )

Génère une signature SHA-256 de l'image.

Valeurs de retour

Retourne une chaîne contenant la signature SHA-256 de l'image.

Erreurs / Exceptions

Lance une exception ImagickException si une erreur survient.



add a note add a note User Contributed Notes Imagick::getImageSignature
holdoffhunger at gmail dot com 20-May-2012 10:30
The getImageSignature function returns the SHA-256 hash value, which is 256 bits (or 32 bytes) in length.  SHA-256 is part of the SHA-2 set of cryptographic hash functions designed by the NSA, which also includes SHA-224, SHA-384, and SHA-512.  According to Wikipedia, there are some security flaws in it similar to the set of SHA-1 hash functions, which should be fixed with SHA-3, eventually.  Unlike MD5 or the SHA-1 set of cryptographic functions, SHA-2 has had no collisions discovered yet (a collision is an incident where two different pieces of data result in the same hash value from the hashing function).  For the time being, it seems to be the most efficient method for creating a small (32-byte), uniquely-identifiable, generally-secure value for either a file or a piece of data.

Some sample code :

<?php

           
// Author: holdoffhunger@gmail.com
   
        // Imagick Type
        // ---------------------------------------------

   
$imagick_type = new Imagick();
   
       
// Open File
        // ---------------------------------------------
       
   
$file_to_grab = "image_workshop_directory/test.bmp";
   
   
$file_handle_for_viewing_image_file = fopen($file_to_grab, 'a+');
   
       
// Grab File
        // ---------------------------------------------

   
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
   
       
// Get Image SHA-256 Signature / Hash Value
        // ---------------------------------------------
       
   
$imagick_type_signature = $imagick_type->getImageSignature();
   
       
// Print Image Signature / Hash Value
        // ---------------------------------------------
       
   
print($imagick_type_signature);

?>

Results of this done on a standard BMP image :

cb2f387a7b23d11340ad1f5ba9c765125ea6b2d50a0d25412abe1ce568adac68

 
show source | credits | sitemap | contact | advertising | mirror sites