In den Wikipedia-Artikel ist ein super (sogar Pascal ähnlicher) Pseudocode:
Delphi-Quellcode:
function hmac (key, message)
if (length(key) > blocksize) then
key = hash(key) // keys longer than blocksize are shortened
else if (length(key) < blocksize) then
key = key ∥ zeroes(blocksize - length(key)) // keys shorter than blocksize are zero-padded
end if
opad = [0x5c * blocksize] ⊕ key // Where blocksize is that of the underlying hash function
ipad = [0x36 * blocksize] ⊕ key // Where ⊕ is exclusive or (XOR)
return hash(opad ∥ hash(ipad ∥ message)) // Where ∥ is concatenation
end function
Da brauchst nicht viel ändern. Anstatt der Funktion Hash verwendest einfach SHA256 aus dem
DEC.