Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjohnson/aspnetmembershipphp
A port of the ASP.NET Membership password hashing in PHP for migrating user data
https://github.com/kjohnson/aspnetmembershipphp
Last synced: 13 days ago
JSON representation
A port of the ASP.NET Membership password hashing in PHP for migrating user data
- Host: GitHub
- URL: https://github.com/kjohnson/aspnetmembershipphp
- Owner: kjohnson
- Created: 2020-04-16T16:32:16.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-16T17:16:46.000Z (almost 5 years ago)
- Last Synced: 2024-11-10T07:24:13.207Z (2 months ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aspNetMembershipPHP
A port of the ASP.NET Membership password hashing in PHP for migrating user data## Usage
```php
$hash = new \AspNetMembershipPHP\Hash( $password, $salt );
$isAuth = (bool) $hash->compareHash( $knownHash );
```## ASP.NET Implementation
The following is a reduced implementation of the ASP.NET password hashing for comparison. For more specific details, see [System.Web/Security/SQLMembershipProvider.cs](https://referencesource.microsoft.com/#System.Web/Security/SQLMembershipProvider.cs,1900).
```c#
byte[] bIn = Encoding.Unicode.GetBytes(password);
byte[] bSalt = Convert.FromBase64String(salt);
byte[] bRet = null;HashAlgorithm hm = new SHA1CryptoServiceProvider();
byte[] bAll = new byte[bSalt.Length + bIn.Length];
Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length);
Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length);
bRet = hm.ComputeHash(bAll);string hash = Convert.ToBase64String(bRet);
```