public override Buf toDigest(string algorithm)
{
string alg = algorithm;
if (alg == "SHA-1") alg = "SHA1"; // to make .NET happy
HashAlgorithm ha = HashAlgorithm.Create(alg);
if (ha == null)
throw ArgErr.make("Unknown digest algorthm: " + algorithm).val;
try
{
long oldPos = getPos();
long size = getSize();
byte[] temp = this.temp();
setPos(0);
long total = 0;
while (total < size)
{
int n = m_stream.Read(temp, (int)total, (int)(size-total));
total += n;
}
setPos(oldPos);
return new MemBuf(ha.ComputeHash(temp, 0, (int)size));
}
catch (IOException e)
{
throw IOErr.make(e).val;
}
}