Answer the question
In order to leave comments, you need to log in
An analogue of a handwritten signature. How can it be implemented in php?
Hello!
In my TOR for the development of the site, the implementation of the ASP is indicated.
By analogy with the site https://www.zaymer.ru/pages/viewPdf/signature_anal... (ASP has already been implemented on this site)
How can it be implemented?
As I understand it, a Simple Electronic Signature with confirmation via SMS is enough for this.
Will the following algorithm be considered PEP:
<?php
function getHMACsms(){
$key = 'тут закрытый ключ';
$return = array();
date_default_timezone_set('UTC');
$timestamp = calc_timestamp();
$code = rand(1000,9999);
$phone = str_replace(array('(',')','-','+'),array('','','',''), $_POST['calc-phone']);
$mac_data = tomacdata($_POST['calc-surname']).
tomacdata($_POST['calc-name']).
tomacdata($_POST['calc-lastname']).
tomacdata($phone).
tomacdata($timestamp).
tomacdata($code);
$return['HMAC'] = hash_hmac("sha1",$mac_data,hex2bin($key));
$return['TIMESTAMP'] = $timestamp;
$ch = curl_init("https://sms.ru/sms/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"api_id" => "тут ключ апи sms.ru",
"to" => $phone,
"text" => "Код согласия с условиями и обязательствами " . $code . ". сайт.рф"
));
$body = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$json["body"] = $body;
if($httpcode == 200 && $body == 100){
return $return;
}else{
return false;
}
}
function tomacdata($oFld)
{
$str="";
if ($oFld == "") {
$str = "-";
} else {
$str = strlen($oFld).$oFld;
}
return $str;
}
function calc_timestamp() {
return date("YmdHis");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question