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

211
Vistas
Why do the standard Java and JavaScript libraries generate different CRC-32 values? How do I get the same result?

Why is the JavaScript crc-32 library, and the Java CRC32 class returning different results? Am I implementing it wrong?

const CRC32 = require('crc-32')
const input = "3b67b67f-673b-4f23-a023-3756f513d707:19.63865368:6ace080f-6f47-44fa-86f8-c278f5bb6f07:2.34121407:42dda603-8a36-4200-826c-80714a40b470:0.923498:1301a851-b77e-489f-beb8-c2b4ef349a90:0.08:bf077871-5709-4a84-b3a9-22bfa8313fa2:0.00382495:6341cbef-bccc-43af-8927-31be3f3cd2e9:1.24039659:aeef18c5-457c-41ca-abda-3940b151e410:0.02821:42943143-bb81-4993-8788-df3c434bce89:0.09:787ef6da-48ce-4bb5-978a-b0fdd9ce223a:0.07:c3850c7b-d0fa-4c2a-8c67-0405bee185da:0.50443922:06429537-15e7-465c-aafa-f9974fb20b95:0.48535755:978d18ba-ffe7-48a3-9642-0de57b249383:0.1:59de5468-be8c-4d56-ad1e-3425914fc081:0.35722062:b6eea705-651b-40db-9b01-e535150ab0f3:0.00408603:6cc9440e-d86b-475d-986e-b9076104873a:1.80178:7711fc0e-dc02-431f-90b8-fde7cd762ce0:0.00402297:58397c47-5cac-424c-9b2b-7dc50c703f6f:0.08"
CRC32.str(input)

# Result: -1990607021
import java.util.zip.CRC32

val input = "3b67b67f-673b-4f23-a023-3756f513d707:19.63865368:6ace080f-6f47-44fa-86f8-c278f5bb6f07:2.34121407:42dda603-8a36-4200-826c-80714a40b470:0.923498:1301a851-b77e-489f-beb8-c2b4ef349a90:0.08:bf077871-5709-4a84-b3a9-22bfa8313fa2:0.00382495:6341cbef-bccc-43af-8927-31be3f3cd2e9:1.24039659:aeef18c5-457c-41ca-abda-3940b151e410:0.02821:42943143-bb81-4993-8788-df3c434bce89:0.09:787ef6da-48ce-4bb5-978a-b0fdd9ce223a:0.07:c3850c7b-d0fa-4c2a-8c67-0405bee185da:0.50443922:06429537-15e7-465c-aafa-f9974fb20b95:0.48535755:978d18ba-ffe7-48a3-9642-0de57b249383:0.1:59de5468-be8c-4d56-ad1e-3425914fc081:0.35722062:b6eea705-651b-40db-9b01-e535150ab0f3:0.00408603:6cc9440e-d86b-475d-986e-b9076104873a:1.80178:7711fc0e-dc02-431f-90b8-fde7cd762ce0:0.00402297:58397c47-5cac-424c-9b2b-7dc50c703f6f:0.08"
val crC32 = CRC32()
crC32.update(input.toByteArray(Charsets.UTF_8))
crC32.value

# Result 2304360275

How do I make the Kotlin function return the same value as the JavaScript?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

They're not different. They are both the exact same 32-bit value, in one case interpreted as an unsigned 32-bit integer, in the other interpreted as a two's complement signed 32-bit integer.

Just cast the Java long value to an int with (int), and you'll get the signed interpretation.

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