Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.crypto
Class SHA256Generator

    java.lang.Object
      net.i2p.crypto.SHA256Generator

    public final class SHA256Generator

extends Object

Defines a wrapper for SHA-256 operation. As of release 0.8.7, uses java.security.MessageDigest by default. If that is unavailable, it uses GNU-Crypto `Sha256Standalone`

Constructor Summary
`SHA256Generator(I2PAppContext context)`

Method Summary
`Hash` | `calculateHash(byte[] source)` Calculate the SHA-256 hash of the source and cache the result.
`Hash` | `calculateHash(byte[] source, int start, int len)` Calculate the hash and cache the result.
`void` | `calculateHash(byte[] source, int start, int len, byte[] out, int outOffset)` Use this if you only need the data, not a Hash object.
`static SHA256Generator` | `getInstance()`
`static void` | `main(String[] args)` Test the GNU and the JVM's implementations for speed Results: 2011-05 eeepc Atom

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SHA256Generator

    public SHA256Generator(I2PAppContext context)

Parameters:
  `context` - unused

Method Detail

### getInstance

    public static final SHA256Generator getInstance()

### calculateHash

    public final Hash calculateHash(byte[] source)

  Calculate the SHA-256 hash of the source and cache the result.

  Parameters:
    `source` - what to hash
  Returns:
    hash of the source

### calculateHash

    public final Hash calculateHash(byte[] source,
                                    int start,
                                    int len)

  Calculate the hash and cache the result.

### calculateHash

    public final void calculateHash(byte[] source,
                                    int start,
                                    int len,
                                    byte[] out,
                                    int outOffset)

  Use this if you only need the data, not a Hash object. Does not cache.

  Parameters:
    `out` - needs 32 bytes starting at outOffset

### main

    public static void main(String[] args)

  Test the GNU and the JVM's implementations for speed Results: 2011-05 eeepc Atom

        JVM   strlen  GNU ms  JVM  ms
              Oracle  387       3861   3565
              Oracle   40        825    635
              Harmony 387       8082   5158
              Harmony  40       4137   1753
              JamVM   387      36301  34100
              JamVM    40       7022   6016
              gij     387     125833   4342
              gij      40      22417    988

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD