Skip to content

Instantly share code, notes, and snippets.

@ToshY
Created September 5, 2020 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToshY/f04ecad95923ea650203f98e69fdc0e2 to your computer and use it in GitHub Desktop.
Save ToshY/f04ecad95923ea650203f98e69fdc0e2 to your computer and use it in GitHub Desktop.
Simple hasher in PHP
<?php
class SimpleHasher{
/*
/* Simple hash
*/
private $hash_algo;
function __construct( $algo = 'sha256' ){
$this->hash_algo = $algo;
}
public function hashString( $user_string ){
return hash( $this->hash_algo, $user_string );
}
}
# Simple Hasher
$hasher = new SimpleHasher('sha512');
# Hash it
$user_hashed_string = $hasher->hashString('Hello World');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment