All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.taig.taigless.hashing.BCryptHashing.scala Maven / Gradle / Ivy

The newest version!
package io.taig.taigless.hashing

import cats.effect.Sync
import cats.implicits._
import org.mindrot.jbcrypt.BCrypt

final class BCryptHashing[F[_]](implicit F: Sync[F]) extends Hashing[F] {
  override def hash(plaintext: String): F[String] = F.delay(BCrypt.hashpw(plaintext, BCrypt.gensalt()))

  override def verify(plaintext: String, hash: String): F[Boolean] = BCrypt.checkpw(plaintext, hash).pure[F]
}

object BCryptHashing {
  def apply[F[_]: Sync]: Hashing[F] = new BCryptHashing[F]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy