Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bouncycastle.crypto.digests;
  
FIPS 180-2 implementation of SHA-512.
         block  word  digest
 SHA-1   512    32    160
 SHA-256 512    32    256
 SHA-384 1024   64    384
 SHA-512 1024   64    512
 
 
 public class SHA512Digest
     extends LongDigest
 {
     private static final int    DIGEST_LENGTH = 64;

    
Standard constructor
 
     public SHA512Digest()
     {
     }

    
Copy constructor. This will copy the state of the provided message digest.
 
     public SHA512Digest(SHA512Digest t)
     {
         super(t);
     }
 
     public SHA512Digest(byte[] encodedState)
     {
         restoreState(encodedState);
     }
 
     public String getAlgorithmName()
     {
         return "SHA-512";
     }
 
     public int getDigestSize()
     {
         return ;
     }
 
     public int doFinal(
         byte[]  out,
         int     outOff)
     {
         finish();
 
         Pack.longToBigEndian(outoutOff);
         Pack.longToBigEndian(outoutOff + 8);
         Pack.longToBigEndian(outoutOff + 16);
         Pack.longToBigEndian(outoutOff + 24);
         Pack.longToBigEndian(outoutOff + 32);
         Pack.longToBigEndian(outoutOff + 40);
         Pack.longToBigEndian(outoutOff + 48);
         Pack.longToBigEndian(outoutOff + 56);
 
         reset();
 
         return ;
     }

    
reset the chaining variables
 
     public void reset()
     {
         super.reset();
 
         /* SHA-512 initial hash value
          * The first 64 bits of the fractional parts of the square roots
          * of the first eight prime numbers
          */
          = 0x6a09e667f3bcc908L;
          = 0xbb67ae8584caa73bL;
          = 0x3c6ef372fe94f82bL;
          = 0xa54ff53a5f1d36f1L;
          = 0x510e527fade682d1L;
          = 0x9b05688c2b3e6c1fL;
          = 0x1f83d9abfb41bd6bL;
          = 0x5be0cd19137e2179L;
     }
 
     public Memoable copy()
     {
         return new SHA512Digest(this);
     }
 
    public void reset(Memoable other)
    {
        SHA512Digest d = (SHA512Digest)other;
        copyIn(d);
    }
    public byte[] getEncodedState()
    {
        byte[] encoded = new byte[getEncodedStateSize()];
        super.populateState(encoded);
        return encoded;
    }
New to GrepCode? Check out our FAQ X