implement digest
but with seg. fault error