org.kde.koala
Class KMD5

java.lang.Object
  extended by org.kde.koala.KMD5
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KMD5
extends java.lang.Object
implements org.kde.qt.QtSupport

The default constructor is designed to provide much the same functionality as the most commonly used C-implementation, while the other three constructors are meant to further simplify the process of obtaining a digest by calculating the result in a single step. KMD5 is state-based, that means you can add new contents with update() as long as you didn't request the digest value yet. After the digest value was requested, the object is "finalized" and you have to call reset() to be able to do another calculation with it. The reason for this behavior is that upon requesting the message digest KMD5 has to pad the received contents up to a 64 byte boundary to calculate its value. After this operation it is not possible to resume consuming data. sage: A common usage of this class:

 String test1;
 KMD5.Digest rawResult;
 test1 = "This is a simple test.";
 KMD5 context (test1);
 cout << "Hex Digest output: " << context.hexDigest().data() << endl;
 
To cut down on the unnecessary overhead of creating multiple KMD5 objects, you can simply invoke reset() to reuse the same object in making another calculation:
 context.reset ();
 context.update ("TWO");
 context.update ("THREE");
 cout << "Hex Digest output: " << context.hexDigest().data() << endl;
 

Author:
Dirk Mueller , Dawit Alemayehu

Constructor Summary
  KMD5()
           
  KMD5(byte[] a)
           
protected KMD5(java.lang.Class dummy)
           
  KMD5(java.lang.String in)
           
  KMD5(java.lang.String in, int len)
          Constructor that updates the digest for the given string.
 
Method Summary
 java.lang.String base64Digest()
          Returns the value of the calculated message digest in a base64-encoded representation.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
protected  void finalizeDigest()
          finalizes the digest
 java.lang.String hexDigest()
          Returns the value of the calculated message digest in a hexadecimal representation.
 void hexDigest(java.lang.StringBuffer arg1)
           
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 void reset()
          Calling this function will reset the calculated message digest.
 void update(byte[] in)
           
 boolean update(org.kde.qt.QIODevice file)
           
 void update(short in)
           
 void update(short in, int len)
           
 void update(java.lang.String in)
           
 void update(java.lang.String in, int len)
          Updates the message to be digested.
 boolean verify(java.lang.String arg1)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KMD5

protected KMD5(java.lang.Class dummy)

KMD5

public KMD5()

KMD5

public KMD5(java.lang.String in,
            int len)
Constructor that updates the digest for the given string.

Parameters:
in - C string or binary data
len - if negative, calculates the length by using strlen on the first parameter, otherwise it trusts the given length (does not stop on NUL byte).

KMD5

public KMD5(java.lang.String in)

KMD5

public KMD5(byte[] a)
Method Detail

update

public void update(java.lang.String in,
                   int len)
Updates the message to be digested. Be sure to add all data before you read the digest. After reading the digest, you can not add more data!

Parameters:
in - message to be added to digest
len - the length of the given message.

update

public void update(java.lang.String in)

update

public void update(short in,
                   int len)

update

public void update(short in)

update

public void update(byte[] in)
Parameters:
in - message to be added to the digest (byte[]).

update

public boolean update(org.kde.qt.QIODevice file)
Parameters:
file - a pointer to FILE as returned by calls like f{d,re}open
Returns:
false if an error occurred during reading.

reset

public void reset()
Calling this function will reset the calculated message digest. Use this method to perform another message digest calculation without recreating the KMD5 object.


hexDigest

public java.lang.String hexDigest()
Returns the value of the calculated message digest in a hexadecimal representation.


hexDigest

public void hexDigest(java.lang.StringBuffer arg1)

base64Digest

public java.lang.String base64Digest()
Returns the value of the calculated message digest in a base64-encoded representation.


verify

public boolean verify(java.lang.String arg1)

finalizeDigest

protected void finalizeDigest()
finalizes the digest


finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?