SHA-256

i have buy the crypto-pac to implement the german fiscal element (TSE)
there are two places where i need it:
- the first, to build a base 64 encoded hash over a string  --> works fine

- the second is follow
  the fiscal element deliver a serial number and a public key base64 coded defined as follow:

tseserialNumber base64 string Raw SHA-256 hash over the public key that belongs to the private key generating signatures. This can be used as Germany fiscal element (TSE)
unique ID.
tsePublicKey
base64 string The public key that belongs to the private key generating
signatures,formatted according to [BSI TR-03111].
This key can be used to verify all signatures created by the Germany fiscal element (TSE).


for verifying i want to extract the the serial number from the publickey by building a sha-256 hash
over the Public key as described, but i get always a different string for the serial number.
the original values in base64 are
serialnumber:
XJmDmoJZDl1cHQXYGlCxjz8n7wiRNwOtQMdtqnFTSFE=
public key:
BAJzAtxxOOWfB3XvtIgY+3M4zws+dvaaNaz7JXJkg0bGbIdLzUegc86a+RTARr2YWWiI1Iba6wp4sZmEAa0OR1/m1XNF8OLfAyrWqyVKGUj+4eTGRyB4hRCw5DR5Rj2wOw==

i hope you can help

Hi, 


You can try the following code to produce the hash from the public key (with rawkey, hash and inputkey, strings, Convert1 TConvert component and SHA2Hash1 TSHA2Hash component)

 
inputKey := 'BAJzAtxxOOWfB3XvtIgY+3M4zws+dvaaNaz7JXJkg0bGbIdLzUegc86a+RTARr2YWWiI1Iba6wp4sZmEAa0OR1/m1XNF8OLfAyrWqyVKGUj+4eTGRyB4hRCw5DR5Rj2wOw==';
Convert1.AType := base64;
rawkey := Convert1.FormatToString(inputKey);
SHA2hash1.outputFormat := TConvertType.base64;
SHA2Hash1.Unicode := noUni;
hash := SHA2Hash1.Hash(rawkey); 


Best regards,
Marion