'' && strlen($_POST['password']) <> 0 ) { $passwordToHash = filter_var ( trim( $_POST['password'] ), FILTER_SANITIZE_SPECIAL_CHARS ); $sha1hash = strtoupper( hash( 'SHA1', $passwordToHash, FALSE ) ); $prefix = substr($sha1hash, 0, 5); $showResult = TRUE; $url = 'https://api.pwnedpasswords.com/range/'; $setupurl = $url . $prefix; $useCURL = FALSE; if( $useCURL ) { $cURLConnection = curl_init(); curl_setopt($cURLConnection, CURLOPT_URL, $setupurl); curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true); $hashList = curl_exec($cURLConnection); curl_close($cURLConnection); } else { $hashList = file_get_contents( $setupurl ); } //echo '
' . print_r( $hashList, TRUE) . '
'; $result = explode("\n", str_replace("\r", "", $hashList)); //echo '
' . print_r( $result, TRUE) . '
'; foreach ($result as $key => $value) { $split = explode( ':', $value); //echo '
' . print_r( $split, TRUE ) . '
'; if ( $prefix . $split[0] == $sha1hash ) { //$result[$key] = '' . $value . ''; $hashfound = TRUE; } } } echo $hashfound;