Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Validating data received via the Web App php

<?php

$data_check_arr = explode('&', rawurldecode($data_check_string));
$needle = 'hash=';
$check_hash = FALSE;
foreach( $data_check_arr AS &$val ){
    if( substr( $val, 0, strlen($needle) ) === $needle ){
        $check_hash = substr_replace( $val, '', 0, strlen($needle) );
        $val = NULL;
    }
}

// if( $check_hash === FALSE ) return FALSE;
$data_check_arr = array_filter($data_check_arr);
sort($data_check_arr);

$data_check_string = implode("
", $data_check_arr);
$secret_key = hash_hmac( 'sha256', $bot_token, "WebAppData", TRUE );
$hash = bin2hex( hash_hmac( 'sha256', $data_check_string, $secret_key, TRUE ) );

if( strcmp($hash, $check_hash) === 0 ){
    // validation success
}else{
    // validation failed
}
Comment

PREVIOUS NEXT
Code Example
Php :: curl outline in laravel 
Php :: gmail smtp not working laravel 
Php :: after i migrate wordpress website to new domain I cant login to wordpress admin 
Php :: add multi product at the same time using repearter default view laravel 
Php :: php browser detection script 
Php :: how to validate students who made payment in php and mysql 
Php :: php explode and typecast 
Php :: php remove new line character from string 
Php :: php find longest string in array 
Php :: laravel components scripts 
Php :: php runden auf 2 stellen 
Php :: how to conditional values in old value or edit new value with validsation faild to redirect back in laravel 
Php :: laravel permit only some inputs 
Php :: laravel slug for non-english words too 
Php :: laravel route namespace and prefix 
Php :: send nested array to laravel resource 
Php :: fichier wp-config.php 
Php :: php text in thml 
Php :: Laravel function to check if image exist or not 
Php :: ubuntu where are laravel logs stored 
Php :: PHP DOMDocument, Unicode problems 
Php :: error import php 
Php :: php -phone number verification 
Php :: Remove WordPress Login error hints 
Php :: display page template using functions.php 
Php :: laravel validate array input 
Php :: how to decode json and combine again in php 
Php :: Laravel Mix npm run production error 
Php :: wordpress wpdb delete 
Php :: scheduling in laravel in custom cron 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =