
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
PasswordHasherLibrary
Advanced tools
PasswordHasherLibrary is a comprehensive, high-security password hashing solution for .NET applications, designed to safeguard user credentials with advanced cryptographic techniques. Utilizing SHA512, custom salts, and an additional pepper value, this library ensures your passwords are protected against brute-force and rainbow table attacks. With features like asynchronous hashing for performance optimization, built-in verification methods to streamline authentication, and a time-constant comparison function to prevent timing attacks, PasswordHasherLibrary delivers a robust, easy-to-integrate approach to password security.
PasswordHasherLibrary is a C# library designed to securely hash and verify passwords using SHA512, along with techniques such as salting, peppering, and timing-attack prevention. It provides both synchronous and asynchronous methods to fit various application needs.
You can install the package via NuGet Package Manager:
dotnet add package PasswordHasherLibrary
Or search for PasswordHasherLibrary
in the NuGet Package Manager in Visual Studio.
Here's how you can use the PasswordHasherLibrary
in your .NET project:
using PasswordHasherLibrary;
class Program
{
static void Main(string[] args)
{
var hasher = new PasswordHasher();
// Hash a password
string password = "my_secure_password";
string hashedPassword = hasher.HashPassword(password);
Console.WriteLine($"Hashed Password: {hashedPassword}");
}
}
using PasswordHasherLibrary;
class Program
{
static void Main(string[] args)
{
var hasher = new PasswordHasher();
string password = "my_secure_password";
string hashedPassword = hasher.HashPassword(password);
// Verify the password
bool isPasswordValid = hasher.VerifyPassword(password, hashedPassword);
Console.WriteLine($"Password is valid: {isPasswordValid}");
}
}
using PasswordHasherLibrary;
using System;
class Program
{
static void Main(string[] args)
{
var hasher = new PasswordHasher();
// Generate a new salt
string salt = hasher.CreateSalt();
Console.WriteLine($"Generated Salt: {salt}");
// Hash a password with salt and pepper
string password = "my_secure_password";
string hashedPassword = hasher.HashPasswordWithSalt(password, salt);
Console.WriteLine($"Hashed Password with Salt: {hashedPassword}");
}
}
using PasswordHasherLibrary;
using System;
class Program
{
static void Main(string[] args)
{
var hasher = new PasswordHasher();
string password = "my_secure_password";
string salt = hasher.CreateSalt();
string hashedPassword = hasher.HashPasswordWithSalt(password, salt);
// Verify the password with salt and pepper
bool isPasswordValid = hasher.VerifyPasswordWithSalt(password, salt, hashedPassword);
Console.WriteLine($"Password is valid: {isPasswordValid}");
}
}
using PasswordHasherLibrary;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var hasher = new PasswordHasher();
// Asynchronously hash a password
string password = "my_secure_password";
string hashedPassword = await hasher.HashPasswordAsync(password);
Console.WriteLine($"Hashed Password: {hashedPassword}");
}
}
using PasswordHasherLibrary;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var hasher = new PasswordHasher();
string password = "my_secure_password";
string hashedPassword = await hasher.HashPasswordAsync(password);
// Asynchronously verify the password
bool isPasswordValid = await hasher.VerifyPasswordAsync("my_secure_password", hashedPassword);
Console.WriteLine($"Password is valid: {isPasswordValid}");
}
}
using PasswordHasherLibrary;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var hasher = new PasswordHasher();
// Generate a new salt
string salt = hasher.CreateSalt();
Console.WriteLine($"Generated Salt: {salt}");
// Asynchronously hash a password with salt and pepper
string password = "my_secure_password";
string hashedPassword = await hasher.HashPasswordWithSaltAsync(password, salt);
Console.WriteLine($"Hashed Password with Salt (Async): {hashedPassword}");
}
}
using PasswordHasherLibrary;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var hasher = new PasswordHasher();
string password = "my_secure_password";
string salt = hasher.CreateSalt();
string hashedPassword = await hasher.HashPasswordWithSaltAsync(password, salt);
// Asynchronously verify the password with salt and pepper
bool isPasswordValid = await hasher.VerifyPasswordWithSaltAsync(password, salt, hashedPassword);
Console.WriteLine($"Password is valid (Async): {isPasswordValid}");
}
}
string HashPassword(string password)
string password
- The password to hash.string
- The hashed password.bool VerifyPassword(string password, string hashedPassword)
string password
- The input password to verify.string hashedPassword
- The stored hashed password to compare against.bool
- true
if the password is valid; otherwise, false
.string HashPasswordWithSalt(string password, string salt)
string password
- The password to hash.string salt
- The unique salt for this password.string
- The hashed password.bool VerifyPasswordWithSalt(string password, string salt, string hashedPassword)
string password
- The input password to verify.string salt
- The salt used for the original hash.string hashedPassword
- The stored hashed password to compare against.bool
- true
if the password is valid; otherwise, false
.Task<string> HashPasswordWithSaltAsync(string password, string salt)
string password
- The password to hash.string salt
- The unique salt for this password.Task<string>
- The hashed password.Task<bool> VerifyPasswordWithSaltAsync(string password, string salt, string hashedPassword)
string password
- The input password to verify.string salt
- The salt used for the original hash.string hashedPassword
- The stored hashed password to compare against.Task<bool>
- true
if the password is valid; otherwise, false
.This project is licensed under the MIT License. See the LICENSE
file for more details.
Developed by Håvard Brækken.
FAQs
PasswordHasherLibrary is a comprehensive, high-security password hashing solution for .NET applications, designed to safeguard user credentials with advanced cryptographic techniques. Utilizing SHA512, custom salts, and an additional pepper value, this library ensures your passwords are protected against brute-force and rainbow table attacks. With features like asynchronous hashing for performance optimization, built-in verification methods to streamline authentication, and a time-constant comparison function to prevent timing attacks, PasswordHasherLibrary delivers a robust, easy-to-integrate approach to password security.
We found that passwordhasherlibrary demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.