Skip to content

Instantly share code, notes, and snippets.

@iarenaza
Created January 23, 2024 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iarenaza/d7e22484f825f188e4fc393918a1ae7e to your computer and use it in GitHub Desktop.
Save iarenaza/d7e22484f825f188e4fc393918a1ae7e to your computer and use it in GitHub Desktop.
Minimal example of interop repro for a babashka script
(ns bb-repro.core
(:import (at.favre.lib.crypto.bcrypt BCrypt
BCrypt$Version)))
(defn pwhash-bcrypt
[password {:keys [iterations]
:or {iterations 12}}]
(let [hasher (BCrypt/with BCrypt$Version/VERSION_2Y)]
(.hashToString hasher iterations (.toCharArray password))))
(comment
(pwhash-bcrypt "123" {})
;; => "$2y$12$Bx7kvYuFlPF5E50aVHVSzeDykOu2pnuSoWMUKul5fSAf7PAzEqoVq"
)
{:deps
{at.favre.lib/bcrypt {:mvn/version "0.10.2"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment