Gathering detailed insights and metrics for php-bcrypt-converter
Gathering detailed insights and metrics for php-bcrypt-converter
Gathering detailed insights and metrics for php-bcrypt-converter
Gathering detailed insights and metrics for php-bcrypt-converter
A Typescript Library that converts PHP bcrypt hashes to JavaScript bcrypt format.
npm install php-bcrypt-converter
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
1,147
Last Day
1
Last Week
4
Last Month
44
Last Year
1,147
MIT License
1 Stars
18 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jan 10, 2025
Latest Version
1.2.1
Package Id
php-bcrypt-converter@1.2.1
Unpacked Size
42.89 kB
Size
6.34 kB
File Count
13
NPM Version
10.8.1
Node Version
20.16.0
Published on
Jan 03, 2025
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-33.3%
4
Compared to previous week
Last Month
-38.9%
44
Compared to previous month
Last Year
0%
1,147
Compared to previous year
5
A TypeScript package for converting PHP bcrypt hashes to JavaScript bcrypt format. This package helps maintain compatibility between PHP and JavaScript applications that use bcrypt hashing.
$2y$
) to JavaScript format ($2b$
)1npm install php-bcrypt-converter 2# or 3yarn add php-bcrypt-converter
1import { PhpBcryptConverter } from 'php-bcrypt-converter'; 2 3const converter = new PhpBcryptConverter(); 4 5// Convert a PHP bcrypt hash 6const result = converter.convert('$2y$10$abcdefghijklmnopqrstuv.wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); 7 8if (result.success) { 9 console.log(result.hash); // '$2b$10$abcdefghijklmnopqrstuv.wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 10 console.log(result.rounds); // 10 11} else { 12 console.error(result.error); 13}
1const options = { 2 rounds: 12, // Default rounds if needed 3 strict: false // Don't throw errors for invalid hashes 4}; 5 6const result = converter.convert(phpHash, options);
1// Strict mode (default) 2try { 3 const result = converter.convert(invalidHash); 4} catch (error) { 5 console.error('Invalid hash format'); 6} 7 8// Non-strict mode 9const result = converter.convert(invalidHash, { strict: false }); 10if (!result.success) { 11 console.error(result.error); 12}
Creates a new instance of the converter.
Converts a PHP bcrypt hash to JavaScript format.
phpHash
: The PHP bcrypt hash to convertoptions
(optional): Configuration options
rounds
: Default number of rounds (default: 12)strict
: Whether to throw errors for invalid hashes (default: true)A ConversionResult
object containing:
hash
: The converted JavaScript bcrypt hashrounds
: Number of rounds detected from the hashsuccess
: Whether the conversion was successfulerror
: Error message if conversion failed (only in non-strict mode)1interface ConversionOptions { 2 rounds?: number; 3 strict?: boolean; 4} 5 6interface ConversionResult { 7 hash: string; 8 rounds: number; 9 success: boolean; 10 error?: string; 11}
1git clone https://github.com/Dippys/php-bcrypt-converter.git 2cd php-bcrypt-converter 3npm install
1npm test 2npm run test:watch # Run tests in watch mode
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENCE file for details.
For support, please open an issue in the GitHub repository.
No vulnerabilities found.
No security vulnerabilities found.