Convert Certificate Serial Number Hex To Decimal Direct
def hex_serial_to_decimal(hex_string): """ Convert a certificate serial number from hex to decimal. Args: hex_string (str): Hex string (with or without '0x' prefix, spaces, or colons) Returns: int: Decimal representation """ # Remove common separators and prefixes cleaned = hex_string.replace(':', '').replace(' ', '').lower() if cleaned.startswith('0x'): cleaned = cleaned[2:] # Convert hex to decimal decimal_value = int(cleaned, 16) return decimal_value
openssl x509 -in certificate.pem -noout -serial | cut -d= -f2 | tr -d '\n' | while read hex; do echo "ibase=16; $hex" | bc; done convert certificate serial number hex to decimal
echo "ibase=16; $(echo '1A:3F' | tr -d ':')" | bc (to view a cert's serial in decimal): do echo "ibase=16
