Last active
October 26, 2017 13:19
-
-
Save ladaposamuel/717dd74326865e98efe3c8378ff49363 to your computer and use it in GitHub Desktop.
Laravel Validation rule for bitcoin adress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function passes($attribute, $address) | |
{ | |
$decoded = decodeBase58($address); | |
$d1 = hash("sha256", substr($decoded,0,21), true); | |
$d2 = hash("sha256", $d1, true); | |
if(substr_compare($decoded, $d2, 21, 4)){ | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment