Giter VIP home page Giter VIP logo

php-blake2's Introduction

PHP BLAKE2 Extension

Build Status

BLAKE2 is an improved version of BLAKE, one the finalists in the NIST SHA-3 competition. Like BLAKE or SHA-3, BLAKE2 offers the highest security, yet is fast as MD5 on 64-bit platforms and requires at least 33% less RAM than SHA-2 or SHA-3 on low-end systems. This implementation uses the BLAKE2b variant of the algorithm which is optimized for 64-bit systems. The algorithm was designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn, and Christian Winnerlein.

Installation

Clone the repository and compile it:

$ git clone [email protected]:strawbrary/php-blake2.git
$ cd php-blake2
$ phpize
$ ./configure --enable-blake2
$ make && sudo make install

Enable the extension by adding the following line to your php.ini file:

extension=blake2.so

You may need to restart your web server to load the extension.

Usage

string blake2 ( string $str [, int $outputSize = 64, string $key, bool $rawOutput = false ] )
  • $str: The string to hash

  • $outputSize: The length of the output hash (can be between 1 and 64)

  • $key: Turns the output into a keyed hash using the specified key

  • $rawOutput: If set to true, then the hash is returned in raw binary format

  • Return value: A hex string containing the BLAKE2 hash of the input string

string blake2b ( string $str [, int $outputSize = 64, string $key, bool $rawOutput = false ] )

is an alias to blake2

string blake2s ( string $str [, int $outputSize = 32, string $key, bool $rawOutput = false ] )
  • $str: The string to hash

  • $outputSize: The length of the output hash (can be between 1 and 32)

  • $key: Turns the output into a keyed hash using the specified key

  • $rawOutput: If set to true, then the hash is returned in raw binary format

  • Return value: A hex string containing the BLAKE2s hash of the input string

string blake2_file ( string $filename [, bool $rawOutput = false ] )
  • $filename: The filename of the file to hash

  • $rawOutput: If set to true, then the hash is returned in raw binary format

  • Return value: A hex string containing the BLAKE2 hash of the input file

string b2sum ( string $filename [, bool $rawOutput = false ] )

is an alias to blake2_file

Examples

echo blake2('');

786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce

echo blake2('Hello world', 20);

5ad31b81fc4dde5554e36af1e884d83ff5b24eb0

echo blake2('Hello world', 20, 'foobar');

5b4bbc84b59ab5d9146089b143fd52f38638dcac

echo blake2s('');

Outputs : 69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9

echo b2sum('tests/sample.txt');

Outputs : a61b779ff667fbcc4775cbb02cd0763b9b5312fe6359a44a003f582ce6897c81a38a876122ce91dfec547d582fe269f6ea9bd291b60bccf95006dac10a4316f2

More Info

https://blake2.net/

php-blake2's People

Contributors

strawbrary avatar 7snovic avatar nikos06 avatar croensch avatar

Watchers

 avatar

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.