/**
 * Copyright 2013 Bruno Oliveira, and individual contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.abstractj.kalium.crypto;

import org.abstractj.kalium.encoders.Encoder;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import static org.abstractj.kalium.NaCl.Sodium.BLAKE2B_OUTBYTES;
import static org.abstractj.kalium.NaCl.Sodium.SHA256BYTES;
import static org.abstractj.kalium.NaCl.Sodium.SHA512BYTES;
import static org.abstractj.kalium.NaCl.sodium;

public class Hash {

    private static byte[] buffer;

    public byte[] sha256(byte[] message) {
        buffer = new byte[SHA256BYTES];
        sodium().crypto_hash_sha256_ref(buffer, message, message.length);
        return buffer;
    }

    public byte[] sha512(byte[] message) {
        buffer = new byte[SHA512BYTES];
        sodium().crypto_hash_sha512_ref(buffer, message, message.length);
        return buffer;
    }

    public String sha256(String messsage, Encoder encoder) {
        byte[] hash = sha256(messsage.getBytes());
        return encoder.encode(hash);
    }

    public String sha512(String messsage, Encoder encoder) {
        byte[] hash = sha512(messsage.getBytes());
        return encoder.encode(hash);
    }


    public byte[] blake2(byte[] message) throws NotImplementedException {
        if (!blakeSupportedVersion()) throw new NotImplementedException();

        buffer = new byte[BLAKE2B_OUTBYTES];
        sodium().crypto_generichash_blake2b(buffer, BLAKE2B_OUTBYTES, message, message.length, null, 0);
        return buffer;
    }

    public String blake2(String message, Encoder encoder) throws NotImplementedException {
        if (!blakeSupportedVersion()) throw new NotImplementedException();
        byte[] hash = blake2(message.getBytes());
        return encoder.encode(hash);
    }

    private boolean blakeSupportedVersion(){
        return sodium().sodium_version_string().compareTo("0.4.0") >= 0 ;
    }

}

@@ -705,79 +705,8 @@
 der;
-%0Aimport sun.reflect.generics.reflectiveObjects.NotImplementedException;
 %0A%0Aim
@@ -1395,33 +1395,32 @@
 a256(String mess
-s
 age, Encoder enc
@@ -1456,25 +1456,24 @@
  sha256(mess
-s
 age.getBytes
@@ -1557,17 +1557,16 @@
 ing mess
-s
 age, Enc
@@ -1614,17 +1614,16 @@
 512(mess
-s
 age.getB
@@ -1720,38 +1720,44 @@
 age) throws 
-NotImplemented
+UnsupportedOperation
 Exception %7B%0A
@@ -1800,38 +1800,44 @@
 ) throw new 
-NotImplemented
+UnsupportedOperation
 Exception();
@@ -2083,30 +2083,36 @@
  throws 
-NotImplemented
+UnsupportedOperation
 Exceptio
@@ -2167,22 +2167,28 @@
 new 
-NotImplemented
+UnsupportedOperation
 Exce

Change exception thrown and rename "messsage" => "message"