jeroen / bcrypt

Wrapper for bcrypt in R
Other
18 stars 0 forks source link

bcrypt

Blowfish Password Hashing Algorithm

Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads Github Stars

An R interface to the OpenBSD 'blowfish' password hashing algorithm, as described in "A Future-Adaptable Password Scheme" by Niels Provos. The implementation is derived from the 'py-bcrypt' module for Python which is a wrapper for the OpenBSD implementation.

See Also

This package is mostly to work with existing bcrypt hashes. For new applications consider using scrypt as implemented in sodium::password_store or the script package.

Hello World

# Secret message as a string
passwd <- "supersecret"

# Create the hash
hash <- hashpw(passwd)
hash

# To validate the hash
identical(hash, hashpw(passwd, hash))

# Or use the wrapper
checkpw(passwd, hash)

# Use varying complexity:
hash11 <- hashpw(passwd, gensalt(11))
hash12 <- hashpw(passwd, gensalt(12))
hash13 <- hashpw(passwd, gensalt(13))

# Takes longer to verify (or crack)
system.time(checkpw(passwd, hash11))
system.time(checkpw(passwd, hash12))
system.time(checkpw(passwd, hash13))

Installation

The libbcrypt source code is currently bundled with the package:

install.packages("bcrypt")