Java.Security.MessageDigest Class
Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.

See Also: MessageDigest Members

Syntax

[Android.Runtime.Register("java/security/MessageDigest", DoNotGenerateAcw=true)]
public abstract class MessageDigest : MessageDigestSpi

Remarks

Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence. The original arbitrary-length sequence is the message, and the fixed-length byte sequence is the digest or message digest.

Sample Code

The basic pattern to digest an Java.IO.InputStream looks like this:

java Example

  MessageDigest digester = MessageDigest.getInstance("MD5");
  byte[] bytes = new byte[8192];
  int byteCount;
  while ((byteCount = in.read(bytes)) > 0) {
    digester.update(bytes, 0, byteCount);
  }
  byte[] digest = digester.digest();
 

That is, after creating or resetting a MessageDigest you should call MessageDigest.Update(Byte[], System.Int32, System.Int32) for each block of input data, and then call MessageDigest.Digest to get the final digest. Note that calling digest resets the MessageDigest. Advanced users who want partial digests should clone their MessageDigest before calling digest.

This class is not thread-safe.

See Also

[Android Documentation]

Requirements

Namespace: Java.Security
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1