PHP Hash_copy () function

PHP

Syntax:
hash_copy ($context)
Parameters:This function takes one parameter $context , which is used to specify the hash context returned by the hash_init() function.Return Value:This function returns a copy of the hash context.Below programs illustrate the hash_copy() function in PHP:Program 1:  
// Initialize the increment
// hashing context $context = hash_init ( "sha1" );  
// Copy the context using the hash_copy function $cp_context = hash_copy ( $context );  
// Finish the extra hash
// and return the received digest echo hash_final ( $context ), "" ;  
// Update context hash_update ( $cp_context , "GFG" );  
// Print finalize context echo hash_final ( $cp_context ), "" ; ?>
Exit:
da39a3ee5e6b4b0d3255bfef95601890afd80709 adb536466977c49bebb6317891b58b77d  / pre> Program 2:        
// Initialize the increment
// hashing context $context = hash_init ( "md5" );  
// Copy the context using the hash_copy function $cp_context = hash_copy ( $context );  
// Finish the extra hash
// and return the received digest echo hash_final ( $context ), "" ;  
// Update context hash_update ( $cp_context , "GFG" );  
// Print finalize context echo hash_final ( $cp_context ), "" ; ?>
Exit:
d41d8cd98f00b204e9800998ecf8427e eadc14b80cd2f247f467eb6c7f45fa9b
Link: http://php.net/manual/en /function.hash-copy.php



Get Solution for free from DataCamp guru