예제 #1
0
 public byte[] CalculateHash(byte[] value)
 {
     var digest = new KeccakDigest(256);
     var output = new byte[digest.GetDigestSize()];
     digest.BlockUpdate(value, 0, value.Length);
     digest.DoFinal(output, 0);
     return output;
 }
예제 #2
0
 private void CopyIn(KeccakDigest source)
 {
     Array.Copy(source.state, 0, this.state, 0, source.state.Length);
     Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
     this.rate              = source.rate;
     this.bitsInQueue       = source.bitsInQueue;
     this.fixedOutputLength = source.fixedOutputLength;
     this.squeezing         = source.squeezing;
 }
예제 #3
0
 public KeccakDigest(KeccakDigest source)
 {
     this.state     = new byte[200];
     this.dataQueue = new byte[0xc0];
     this.C         = new ulong[5];
     this.tempA     = new ulong[0x19];
     this.chiC      = new ulong[5];
     this.CopyIn(source);
 }
예제 #4
0
 public string CalculateHash(string value)
 {
     var digest = new KeccakDigest(256);
     var output = new byte[digest.GetDigestSize()];
     var input = Encoding.UTF8.GetBytes(value);
     digest.BlockUpdate(input, 0, input.Length);
     digest.DoFinal(output, 0);
     return output.ToHex();
 }
예제 #5
0
    public static byte[] Keccak(byte[] data)
    {
        var digest = new Org.BouncyCastle.Crypto.Digests.KeccakDigest(256);

        digest.BlockUpdate(data, 0, data.Length);

        byte[] hash = new byte[32];
        digest.DoFinal(hash, 0);

        return(hash);
    }
예제 #6
0
 private void CopyIn(KeccakDigest source)
 {
     Array.Copy(source.state, 0, this.state, 0, source.state.Length);
     Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
     this.rate                      = source.rate;
     this.bitsInQueue               = source.bitsInQueue;
     this.fixedOutputLength         = source.fixedOutputLength;
     this.squeezing                 = source.squeezing;
     this.bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
     this.chunk                     = Arrays.Clone(source.chunk);
     this.oneByte                   = Arrays.Clone(source.oneByte);
 }
예제 #7
0
 private void CopyIn(KeccakDigest source)
 {
     global::System.Array.Copy((global::System.Array)source.state, 0, (global::System.Array)state, 0, source.state.Length);
     global::System.Array.Copy((global::System.Array)source.dataQueue, 0, (global::System.Array)dataQueue, 0, source.dataQueue.Length);
     rate                      = source.rate;
     bitsInQueue               = source.bitsInQueue;
     fixedOutputLength         = source.fixedOutputLength;
     squeezing                 = source.squeezing;
     bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
     chunk                     = Arrays.Clone(source.chunk);
     oneByte                   = Arrays.Clone(source.oneByte);
 }
예제 #8
0
        public virtual void Reset(IMemoable other)
        {
            KeccakDigest d = (KeccakDigest)other;

            CopyIn(d);
        }
예제 #9
0
 public KeccakDigest(KeccakDigest source)
 {
     CopyIn(source);
 }
예제 #10
0
        public virtual void Reset(IMemoable other)
        {
            KeccakDigest source = (KeccakDigest)other;

            CopyIn(source);
        }
예제 #11
0
 private void CopyIn(KeccakDigest source)
 {
     Array.Copy(source.state, 0, this.state, 0, source.state.Length);
     Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
     this.rate = source.rate;
     this.bitsInQueue = source.bitsInQueue;
     this.fixedOutputLength = source.fixedOutputLength;
     this.squeezing = source.squeezing;
     this.bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
     this.chunk = Arrays.Clone(source.chunk);
     this.oneByte = Arrays.Clone(source.oneByte);
 }
예제 #12
0
 public KeccakDigest(KeccakDigest source)
 {
     CopyIn(source);
 }