PHP - Implentar un ipad de firm

 
Vista:
sin imagen de perfil

Implentar un ipad de firm

Publicado por Pablo (5 intervenciones) el 02/01/2023 17:18:41
Hola buenos días estoy creando una pagina web y el cliente quiere que le coloque un ipad de firmas alguien sabe como ponerla necesito ayuda ya que es la primera vez que lo intento y no se como hacerlo tengo un codigo pero no se si me funcione ya que lo estoy creando en php ente es el codigo qur tengo:
<?php
//Datos que se quieren firmar:
$datos = 'Este texto será firmado. Thanks for your attention :)';
//Se deben crear dos claves aparejadas, una clave pública y otra privada
//A continuación el array de configuración para la creación del juego de claves
$configArgs = array(
'config' => 'C:\xampp5_6_15\php\extras\openssl\openssl.cnf', //<-- esta ruta es necesaria si trabajas con XAMPP
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA
);
$resourceNewKeyPair = openssl_pkey_new($configArgs);
if (!$resourceNewKeyPair) {
echo 'Puede que tengas problemas con la ruta indicada en el array de configuración "$configArgs" ';
echo openssl_error_string(); //en el caso que la función anterior de openssl arrojará algun error, este sería visualizado gracias a esta línea
exit;
}
//obtengo del recurso $resourceNewKeyPair la clave publica como un string
$details = openssl_pkey_get_details($resourceNewKeyPair);
$publicKeyPem = $details['key'];
//obtengo la clave privada como string dentro de la variable $privateKeyPem (la cual es pasada por referencia)
if (!openssl_pkey_export($resourceNewKeyPair, $privateKeyPem, NULL, $configArgs)) {
echo openssl_error_string(); //en el caso que la función anterior de openssl arrojará algun error, este sería visualizado gracias a esta línea
exit;
}
//guardo la clave publica y privada en disco:
file_put_contents('private_key.pem', $privateKeyPem);
file_put_contents('public_key.pem', $publicKeyPem);
//si bien ya tengo cargado el string de la clave privada, lo voy a buscar a disco para verificar que el archivo private_key.pem haya sido correctamente generado:
$privateKeyPem = file_get_contents('private_key.pem');
//obtengo la clave privada como resource desde el string
$resourcePrivateKey = openssl_get_privatekey($privateKeyPem);
//crear la firma dentro de la variable $firma (la cual es pasada por referencia)
if (!openssl_sign($datos, $firma, $resourcePrivateKey, OPENSSL_ALGO_SHA256)) {
echo openssl_error_string(); //en el caso que la función anterior de openssl arrojará algun error, este sería visualizado gracias a esta línea
exit;
}
// guardar la firma en disco:
file_put_contents('signature.dat', $firma);
// comprobar la firma
if (openssl_verify($datos, $firma, $publicKeyPem, 'sha256WithRSAEncryption') === 1) {
echo 'la firma es valida y los datos son confiables';
} else {
echo 'la firma es invalida y/o los datos fueron alterados';
}
?>
no se si funcione ya que el ipad de firmas que tengo que implementar es el wacom stu-300 agradercesria much la ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 393
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Implentar un ipad de firm

Publicado por Jefferson (203 intervenciones) el 02/01/2023 21:08:22
Hola no entiendo mucho la pregunta.

Intentas generar certificados legibles por PEM y el jefe te solicita una pad de firmas para usar la tablet wacom stu-300
algo no encaja??

Si lo que creo es que quieres guardar la firma digital, puedes usar la biblioteca https://github.com/szimek/signature_pad

Ahora bien si aun deseas usar la tablet wacom stu-300, se complica aun mas la cosa y también podrías usa la biblioteca https://github.com/Wacom-Developer/signature-sdk-js

El amigo https://stackoverflow.com/users/2578125/oxigen nos muestra una forma sencilla de capturar la firma digital

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
<style>
svg {
  margin: .5em;
  border: 1px solid gray;
  border-radius: .5em;
}
.flex {
  display: flex;
}
button {
  margin: .5em;
}
#pathdata {
  font-family: monospace;
  background: #ddd;
  padding: 1em;
  margin: 1em .5em;
}
</style>
</head>
<body>
<svg id="sig_panel" xmlns="http://www.w3.org/2000/svg" width="400" height="200" viewBox="0 0 400 200">
  <rect id="r" width="400" height="200" fill="#ffa"/>
  <line x1="0" y1="190" x2="400" y2="190" stroke="#666" stroke-width="1" stroke-dasharray="3" shape-rendering="crispEdges" pointer-events="none"/>
  <path id="p" stroke="navy" stroke-width="2" fill="none" pointer-events="none"/>
</svg>
<div class="flex">
  <button id="show">Show signaure path data</button>
  <button id="clear">Clear signature</button>
</div>
<div id="pathdata"></div>
<script>
//init
let r = document.getElementById('r'),
  p = document.getElementById('p'),
  signaturePath = '',
  isDown = false,
  svg = document.getElementById('sig_panel'),
  b_show = document.getElementById('show'),
  b_clear = document.getElementById('clear'),
  pathdata = document.getElementById('pathdata');
 
//drawing functions
function isTouchEvent(e) {
  return e.type.match(/^touch/);
}
function getCoords(e) {
  if (isTouchEvent(e)) {
    return e.targetTouches[0].clientX + ',' + e.targetTouches[0].clientY;
  }
  return e.clientX + ',' + e.clientY;
}
function down(e) {
  signaturePath += 'M' + getCoords(e) + ' ';
  p.setAttribute('d', signaturePath);
  isDown = true;
 
  if (isTouchEvent(e)) e.preventDefault();
}
function move(e) {
  if (isDown) {
    signaturePath += 'L' + getCoords(e) + ' ';
    p.setAttribute('d', signaturePath);
  }
  if (isTouchEvent(e)) e.preventDefault();
}
function up(e) {
  isDown = false;
  if (isTouchEvent(e)) e.preventDefault();
}
//input handlers
r.addEventListener('touchstart', down, false);
r.addEventListener('touchmove', move, false);
r.addEventListener('touchend', up, false);
r.addEventListener('mousedown', down, false);
r.addEventListener('mousemove', move, false);
r.addEventListener('mouseup', up, false);
r.addEventListener('mouseout', up, false);
//helper functions
function clearSignature() {
  pathdata.textContent = '';
  signaturePath = '';
  p.setAttribute('d', '');
}
function getSignature() {
  pathdata.textContent = signaturePath;
  return signaturePath;
}
//button handlers
b_show.addEventListener('click', getSignature);
b_clear.addEventListener('click', clearSignature);
</script>
</body>
</html>

Si estoy equivocado por favor corrígeme

Saludos Jefferson
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar