XBRL-Signer.php
public function sign_taxonomy( $source, $private_key_pem, $signature_alg = "SHA256" )
	{
		$json = $source;
		$filename = $this->get_source_filename( $source );

		if ( $filename )
		{
			$json = $this->get_json( $filename );
		}

		$taxonomy = $this->get_taxonomy( $json );

		// Is there a signature?  If so remove it and re-generate the string
		if ( isset( $taxonomy['signature_block'] ) )
		{
			unset( $taxonomy['signature_block'] );
			$json = json_encode( $taxonomy );
		}

		$signature = $this->generate_signature( $json, $private_key_pem, $signature_alg );
		$taxonomy['signature_block'] = array(
				'signature' => $signature,
				'algorithm' => 'sha256',
		);

		$json = json_encode( $taxonomy );

		if ( $filename )
		{
			$this->save_json( $json, $filename );
			return true;
		}
		else
		{
			return $json;
		}
	}
public function sign_taxonomy( $source, $private_key_pem, $signature_alg = "SHA256" )
	{
		$json = $source;
		$filename = $this->get_source_filename( $source );

		if ( $filename )
		{
			$json = $this->get_json( $filename );
		}

		$taxonomy = $this->get_taxonomy( $json );

		// Is there a signature?  If so remove it and re-generate the string
		if ( isset( $taxonomy['signature_block'] ) )
		{
			unset( $taxonomy['signature_block'] );
			$json = json_encode( $taxonomy );
		}

		$signature = $this->generate_signature( $json, $private_key_pem, $signature_alg );
		$taxonomy['signature_block'] = array(
				'signature' => $signature,
				'algorithm' => 'sha256',
		);

		$json = json_encode( $taxonomy );

		if ( $filename )
		{
			$this->save_json( $json, $filename );
			return true;
		}
		else
		{
			return $json;
		}
	}
public function sign_taxonomy ( $ source , $ private_key_pem , $ signature_alg = "SHA256" ) { $ json = $ source ; $ filename = $ this -> get_source_filename ( $ source ) ; if ( $ filename ) { $ json = $ this -> get_json ( $ filename ) ; } $ taxonomy = $ this -> get_taxonomy ( $ json ) ; // Is there a signature?  If so remove it and re-generate the string
 if ( isset ( $ taxonomy [ 'signature_block' ] ) ) { unset ( $ taxonomy [ 'signature_block' ] ) ; $ json = json_encode ( $ taxonomy ) ; } $ signature = $ this -> generate_signature ( $ json , $ private_key_pem , $ signature_alg ) ; $ taxonomy [ 'signature_block' ] = array ( 'signature' => $ signature , 'algorithm' => 'sha256' , ) ; $ json = json_encode ( $ taxonomy ) ; if ( $ filename ) { $ this -> save_json ( $ json , $ filename ) ; return true ; } else { return $ json ; } }
Sign and save the signed taxonomy.
@param string $source The source of the JSON
@param string $private_key_pem  Path to a PEM formatted file containing the private key or a string containing the private key
@param string $signature_alg The name the hash algorithm to use (Default: SHA256)
@return string
Sign and save the signed taxonomy .