Coder Social home page Coder Social logo

crazy-max / cwscrypto Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 155 KB

PHP class for password hashing with multi encryption methods

License: MIT License

PHP 100.00%
encryption-key php openbsd-style-blowfish pbkdf2 random-bytes bcrypt encryption-methods blowfish-algorithm

cwscrypto's Introduction

Latest Stable Version Minimum PHP Version Build Status Code Quality Become a sponsor Donate Paypal

โš ๏ธ Abandoned project

This project is not maintained anymore and is abandoned. Feel free to fork and make your own changes if needed.

Thanks to everyone for their valuable feedback and contributions.

About

PHP class for password hashing with multi encryption methods.

Overview

The PBKDF2 key derivation function

Defined by RSA's PKCS #5: https://www.ietf.org/rfc/rfc2898.txt
This implementation of PBKDF2 was originally created by https://defuse.ca/php-pbkdf2.htm
With improvements by http://www.variations-of-shadow.com

The OpenBSD-style Blowfish-based bcrypt

This hashing method is known in PHP as CRYPT_BLOWFISH.
More infos : http://www.php.net/security/crypt_blowfish.php
This implementation of BCRYPT was originally created by http://www.openwall.com/phpass/

Generate random bytes

A random() function is available to generate secure random bytes with 5 methods :

Encrypt/Decrypt datas

There is also a method to encrypt/decrypt data using a symectric encryption string with the blowfish algorithm and an encryption key in CFB mode but please be advised that you should not use this method for truly sensitive data.

Installation

composer require crazy-max/cws-crypto

And download the code:

composer install # or update

Getting started

See tests/test.php file sample to help you.

Example

Methods

hashPassword - Create a password hash.
checkPassword - Check a hash with the password given.
encrypt - Generate a symectric encryption string with the blowfish algorithm and an encryption key in CFB mode.
decrypt - Return the decrypted string generated from the encrypt method.
random - Generate secure random bytes with 5 methods : mcrypt_create_iv, openssl_random_pseudo_bytes, GetRandom() from CAPICOM Microsoft class, /dev/urandom on Unix systems or mt_rand() and getmypid() functions.

setPbkdf2Mode - Set the pbkdf2 mode for hashing/check password.
setBcryptMode - Set the bcrypt mode for hashing/check password. (default)
setEncryptionKey - Set the encryption key for encrypt/decrypt method (max length 56).
getError - Get the last error.

How can I help ?

All kinds of contributions are welcome ๐Ÿ™Œ! The most basic way to show your support is to star ๐ŸŒŸ the project, or to raise issues ๐Ÿ’ฌ You can also support this project by becoming a sponsor on GitHub ๐Ÿ‘ or by making a Paypal donation to ensure this journey continues indefinitely! ๐Ÿš€

Thanks again for your support, it is much appreciated! ๐Ÿ™

License

MIT. See LICENSE for more details.

cwscrypto's People

Contributors

crazy-max avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cwscrypto's Issues

Microtime is not realy random

Why don't use mt_rand() like ?

for ($i = 0; $i < $length; $i += 16) {
$state = md5( mt_rand() .$state);
$bytes .= pack('H*', md5($state));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.