Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
intente generar una firma usando HMACSHA512 en C#

firma en c# usando HMACSHA512 no equivalente a java y JavaScript. después de rastrear mi código C #, encontré que la clave no se usa durante la generación de la firma.

 using System.Security.Cryptography; using System.Text; string privateKey = "OPAYPRV16388855997950.6319778282304234"; string message = "{\r\n \"country\": \"EG\",\r\n \"reference\": \"9cf357a79ffc4cb5a57cd0489a1a4bfa\"\r\n}"; byte[] messagebyte = Encoding.Default.GetBytes(message); byte[] pkey = Encoding.Default.GetBytes(privateKey); HMACSHA512 hMACSHA512 = new HMACSHA512(pkey); //hMACSHA512.Key = pkey; //other way and not give right signature //hmacsha512.Initialize(); var hmac = hMACSHA512.ComputeHash(messagebyte); var hmacres = BitConverter.ToString(hmac).Replace("-", ""); Console.WriteLine(hmacres); // signature c# =FC96AABB47DE439A78CB98943BA3E9F9C25B24264E1431CC4180348F5B48C869F9003E3B67B8E387D25A7189093ACDD90205A103A489856379971EBE07E295E5 // signature in java and JavaScript (the same and the right signature)= 20c8b06951a7907b48db0ccb0b1fb514e8addb2b7c72786cc21316576d57e57560188cac837ffe232a9b24e65e73c6c05e6a5dddff3cc03e26521c92e74e064d
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

HMACSHA512 trata con \r\n y espacios como caracteres, cuando eliminé /r/n y espacio obtuve la firma correcta

mensaje= mensaje.Reemplazar(Sistema.Entorno.NuevaLínea, cadena.Vacío).Reemplazar(" ", "");

byte[] mensajebyte = Codificación.Predeterminado.GetBytes(mensaje);

byte[] pkey = Codificación.Default.GetBytes(privateKey);

HMACSHA512 hMACSHA512 = nuevo HMACSHA512(pkey);

var hmac = hMACSHA512.ComputeHash(mensajebyte);

var hmacres = BitConverter.ToString(hmac).Replace("-", "");

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda