diff --git a/js/src/main/scala/fluence/crypto/hash/CryptoHashers.scala b/js/src/main/scala/fluence/crypto/hash/CryptoHashers.scala
new file mode 100644
index 0000000..7d22bee
--- /dev/null
+++ b/js/src/main/scala/fluence/crypto/hash/CryptoHashers.scala
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 Fluence Labs Limited
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package fluence.crypto.hash
+
+object CryptoHashers {
+ lazy val Sha1: CryptoHasher.Bytes = JsCryptoHasher.Sha1
+
+ lazy val Sha256: CryptoHasher.Bytes = JsCryptoHasher.Sha256
+}
diff --git a/js/src/main/scala/fluence/crypto/hash/JsCryptoHasher.scala b/js/src/main/scala/fluence/crypto/hash/JsCryptoHasher.scala
index a1c9b19..7a8d880 100644
--- a/js/src/main/scala/fluence/crypto/hash/JsCryptoHasher.scala
+++ b/js/src/main/scala/fluence/crypto/hash/JsCryptoHasher.scala
@@ -24,7 +24,7 @@ import scala.scalajs.js.JSConverters._
object JsCryptoHasher {
- lazy val Sha256: CryptoHasher[Array[Byte], Array[Byte]] = new CryptoHasher[Array[Byte], Array[Byte]] {
+ lazy val Sha256: CryptoHasher.Bytes = new CryptoHasher[Array[Byte], Array[Byte]] {
override def hash(msg1: Array[Byte]): Array[Byte] = {
val sha256 = new SHA256()
sha256.update(msg1.toJSArray)
@@ -35,7 +35,7 @@ object JsCryptoHasher {
}
}
- lazy val Sha1: CryptoHasher[Array[Byte], Array[Byte]] = new CryptoHasher[Array[Byte], Array[Byte]] {
+ lazy val Sha1: CryptoHasher.Bytes = new CryptoHasher[Array[Byte], Array[Byte]] {
override def hash(msg1: Array[Byte]): Array[Byte] = {
val sha1 = new SHA1()
sha1.update(msg1.toJSArray)
diff --git a/jvm/src/main/scala/fluence/crypto/hash/CryptoHashers.scala b/jvm/src/main/scala/fluence/crypto/hash/CryptoHashers.scala
new file mode 100644
index 0000000..0c6d0b0
--- /dev/null
+++ b/jvm/src/main/scala/fluence/crypto/hash/CryptoHashers.scala
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 Fluence Labs Limited
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package fluence.crypto.hash
+
+object CryptoHashers {
+ lazy val Sha1: CryptoHasher.Bytes = JdkCryptoHasher.Sha1
+
+ lazy val Sha256: CryptoHasher.Bytes = JdkCryptoHasher.Sha256
+}
diff --git a/jvm/src/main/scala/fluence/crypto/hash/JdkCryptoHasher.scala b/jvm/src/main/scala/fluence/crypto/hash/JdkCryptoHasher.scala
index f20d1c1..315a9d2 100644
--- a/jvm/src/main/scala/fluence/crypto/hash/JdkCryptoHasher.scala
+++ b/jvm/src/main/scala/fluence/crypto/hash/JdkCryptoHasher.scala
@@ -39,9 +39,9 @@ class JdkCryptoHasher(algorithm: String) extends CryptoHasher[Array[Byte], Array
object JdkCryptoHasher {
- lazy val Sha256 = apply("SHA-256")
- lazy val Sha1 = apply("SHA-1")
+ lazy val Sha256: CryptoHasher[Array[Byte], Array[Byte]] = apply("SHA-256")
+ lazy val Sha1: CryptoHasher[Array[Byte], Array[Byte]] = apply("SHA-1")
- def apply(algorithm: String): JdkCryptoHasher = new JdkCryptoHasher(algorithm)
+ def apply(algorithm: String): CryptoHasher[Array[Byte], Array[Byte]] = new JdkCryptoHasher(algorithm)
}
diff --git a/src/main/scala/fluence/crypto/hash/CryptoHasher.scala b/src/main/scala/fluence/crypto/hash/CryptoHasher.scala
index 96a7201..35131ec 100644
--- a/src/main/scala/fluence/crypto/hash/CryptoHasher.scala
+++ b/src/main/scala/fluence/crypto/hash/CryptoHasher.scala
@@ -30,3 +30,7 @@ trait CryptoHasher[M, H] {
def hash(msg1: M, msgN: M*): H
}
+
+object CryptoHasher {
+ type Bytes = CryptoHasher[Array[Byte], Array[Byte]]
+}
\ No newline at end of file