B4J Library [PyBridge] UPDATE PyPasslib – Secure Password Hashing via Python & Passlib

Overview :

PyPasslib is a B4J libray that enables secure password hashing and verification using the PassLib library in Python.
It leverages PyBridge to connect your B4J app to Python, giving you access to modern hashing algorithms like bcrypt and PBKDF2-SHA256.

This is ideal for developers who want to implement strong password security in their B4J apps without relying on outdated or limited native encryption methods.

Requirements :

PyBridge library added to your B4J project
Passlib installed in your Python environment: pip install passlib
bcrypt_4.0.1 installed in your Python environment: pip install "bcrypt==4.0.1"

Available Methods :

HashPassword - Returns a hashed version of the password
VerifyPassword - Verifies if the password matches the hash

Notes :

Supported algorithms: "bcrypt" and "pbkdf2"
Hashes are salted automatically

Usage :
valid algorithms
1 - bcrypt
2 - pbkdf2

B4J:
Private pLib As PyPassLib

' Hash
Wait For (pLib.EncryptPassword(Password, Algo)) Complete (hashed As String)
Log("Hashed password : " & hashed)

' Verification
Wait For (pLib.VerifyPassword(Password, hashed, Algo)) Complete (isValid As Boolean)
Log("Valid password ? " & isValid)


This library is completely free. If you would like to make a donation, please donate to LucaMs.
 

Attachments

  • PyPassLib.b4xlib
    1.3 KB · Views: 6
  • exemple_PyPassLib.zip
    3.5 KB · Views: 4
Last edited:

zed

Well-Known Member
Licensed User
Argon2

Argon2 is a key derivation function (KDF) designed for secure password hashing.
Unlike older algorithms like bcrypt or PBKDF2, Argon2 is designed to:

Resist attacks from GPUs, FPGAs, and ASICs (specialized hardware)
Be configurable in terms of memory, processing time, and parallelism
Provide protection against side-channel attacks (such as timing attacks)

Argon2 Configurable Parameters

time_cost: default: 3 Number of iterations (higher = slower but more secure)
memory_cost: default: 65536 Memory used in KB (e.g., 65536 = 64MB)
parallelism: default: 4 Number of threads used (useful on multi-core machines)

These values offer a good compromise between security and performance, with a typical calculation time around 50–100 ms on a modern machine

Highly secure: Designed to slow brute force attacks
Flexible: Adapts to your environment (server, mobile, etc.)
Recommended: By the IETF as a modern standard for password hashing

Adapt according to context.
Secure server: Increase memory_cost to 131072 or higher.
Mobile or embedded: Reduce memory_cost to 32768 or 16384.
Multi-user: Keep time_cost ≤ 3 to avoid deadlocks.


Scrypt

Scrypt is a hashing algorithm that offers maximum resistance to brute-force attacks, particularly those carried out using specialized hardware such as GPUs or ASICs.
It was designed to make password hashing extremely memory-intensive, making it difficult to parallelize.

Features:

Uses a memory-intensive key bypass function
Ideal for environments where security takes priority over speed

Advantages:

Very robust against hardware attacks
Suitable for modern systems requiring enhanced security
Used in some cryptocurrencies (e.g., Litecoin)
 

zed

Well-Known Member
Licensed User
sha512_crypt

sha512_crypt is a variant of the SHA-512 algorithm, suitable for securely hashing passwords in Unix/Linux systems.
It is based on the crypt() function and produces a 512-bit hash.

Features:
Hash format: $6$salt$hash
Compatible with /etc/shadow files on Linux

Advantages:
Widely used in Unix environments
Good resistance to dictionary attacks
Easy to integrate into existing systems
 
Last edited:

zed

Well-Known Member
Licensed User
I forgot. You need to install the python libs.
pip install passlib
pip install "bcrypt==4.0.1"
pip install argon2-cffi
 
Top