Information Security 7 min read

Password Hashing with PBKDF2 in C# (ASP.NET) and Ruby on Rails

The article presents complete, licensed implementations of salted PBKDF2‑SHA1 password hashing for both ASP.NET (C#) and Ruby on Rails, detailing the source code, usage methods, and verification procedures to securely store and validate passwords.

Architect
Architect
Architect
Password Hashing with PBKDF2 in C# (ASP.NET) and Ruby on Rails

This article provides implementations of salted password hashing using PBKDF2‑SHA1 for both ASP.NET (C#) and Ruby on Rails, including full source code, licensing information, and usage examples.

In C#, the PasswordHash class defines constants for salt size, hash size, and iteration count, and offers CreateHash and ValidatePassword methods that generate a hash string formatted as iterations:salt:hash and verify passwords securely.

The Ruby module PasswordHash mirrors the same functionality, defining comparable constants and providing createHash and validatePassword methods that produce and check hashes using OpenSSL's PBKDF2‑HMAC‑SHA1, with a self‑test routine to confirm correctness.

Both implementations include the original BSD‑style license and attribution to the original author and source (crackstation.net).

C++securityRubyPBKDF2password hashingASP.NET
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.