Hexadécimal en adresse IP

Saisie hexadécimale
Exemple
Adresse IP en sortie

Convertisseur hexadécimal en adresse IP : en ligne et gratuit

Si vous avez besoin de convertir des nombres hexadécimaux en adresses IP, cet outil est pour vous. Il est en ligne, gratuit et ne nécessite aucune dépendance système ou logicielle. Vous pouvez l'utiliser sur n'importe quel appareil, n'importe où et à n'importe quel moment.

Fonctionnalités

Ce convertisseur hexadécimal en adresse IP dispose de plusieurs fonctionnalités pour vous aider dans vos besoins de conversion :

  • En ligne et gratuit : Pas besoin de télécharger ou d'installer un logiciel. Il suffit de visiter le site web et de commencer la conversion.
  • Peut être effacé : Si vous faites une erreur, cliquez simplement sur le bouton "Effacer" pour recommencer.
  • Peut être copié : Une fois que vous avez converti un nombre hexadécimal en adresse IP, vous pouvez le copier dans votre presse-papiers en cliquant sur le bouton "Copier".
  • Possède un exemple : Si vous n'êtes pas sûr de savoir comment utiliser l'outil, vous pouvez utiliser l'option "Exemple".

Avantages

Il existe de nombreux avantages à utiliser ce convertisseur hexadécimal en adresse IP. Par exemple :

  • Sécurité des données : Cet outil ne stocke aucune de vos informations. Tous les calculs sont effectués localement sur votre appareil.
  • Gain de temps : Vous pouvez gagner du temps en utilisant cet outil au lieu de convertir manuellement des nombres hexadécimaux en adresses IP.
  • Facilité d'utilisation : L'outil est convivial et ne nécessite aucune connaissance technique.

Comment utiliser le convertisseur

Pour utiliser ce convertisseur, suivez ces étapes :

  1. Saisissez ou collez votre nombre hexadécimal dans le champ d'entrée.
  2. Cliquez sur le bouton "Convertir".
  3. Le convertisseur convertira le nombre hexadécimal en adresse IP.
  4. Vous pouvez copier l'adresse IP dans votre presse-papiers en cliquant sur le bouton "Copier".

Exemple de code

Si vous êtes un développeur, vous pouvez utiliser le code suivant pour convertir des nombres hexadécimaux en adresses IP dans différents langages de programmation :

Python
def hex_to_ip(hex_num):
    hex_num = hex_num.replace(".", "")
    hex_num = hex_num.replace("0x", "")
    hex_num = hex_num.zfill(8)
    parts = [hex_num[i:i+2] for i in range(0, len(hex_num), 2)]
    ip_addr = ".".join([str(int(part, 16)) for part in parts])
    return ip_addr

hex_num = "7f.00.00.01"
ip_addr = hex_to_ip(hex_num)
print(ip_addr)
C/C++
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>

std::string hex_to_ip(std::string hex_num) {
    hex_num.erase(std::remove(hex_num.begin(), hex_num.end(), '.'), hex_num.end());
    hex_num.erase(std::remove(hex_num.begin(), hex_num.end(), 'x'), hex_num.end());
    std::stringstream ss;
    ss << std::hex << hex_num;
    unsigned int int_num;
    ss >> int_num;
    unsigned char byte_array[4];
    byte_array[0] = (int_num & 0xFF000000) >> 24;
    byte_array[1] = (int_num & 0x00FF0000) >> 16;
    byte_array[2] = (int_num & 0x0000FF00) >> 8;
    byte_array[3] = int_num & 0x000000FF;
    std::stringstream result;
    result << (int) byte_array[0] << "." << (int) byte_array[1] << "." << (int) byte_array[2] << "." << (int) byte_array[3];
    return result.str();
}

int main() {
    std::string hex_num = "7f.00.00.01";
    std::string ip_addr = hex_to_ip(hex_num);
    std::cout << ip_addr << std::endl;
    return 0;
}
JavaScript
function hexToIp(hexNum) {
  hexNum = hexNum.replace(".", "");
  hexNum = hexNum.replace("0x", "");
  hexNum = hexNum.padStart(8, "0");
  let bytes = hexNum.match(/.{1,2}/g).map((byte) => parseInt(byte, 16));
  let ipAddr = bytes.join(".");
  return ipAddr;
}

let hexNum = "7f.00.00.01";
let ipAddr = hexToIp(hexNum);
console.log(ipAddr);
Java
public class HexToIpConverter {
    public static String hexToIp(String hexNum) {
        hexNum = hexNum.replace(".", "");
        hexNum = hexNum.replace("0x", "");
        hexNum = String.format("%8s", hexNum).replace(" ", "0");
        int intNum = Integer.parseInt(hexNum, 16);
        byte[] byteArr = new byte[4];
        byteArr[0] = (byte) ((intNum & 0xFF000000) >>> 24);
        byteArr[1] = (byte) ((intNum & 0x00FF0000) >>> 16);
        byteArr[2] = (byte) ((intNum & 0x0000FF00) >>> 8);
        byteArr[3] = (byte) (intNum & 0x000000FF);
        String ipAddr = String.format("%d.%d.%d.%d", byteArr[0] & 0xFF, byteArr[1] & 0xFF, byteArr[2] & 0xFF, byteArr[3] & 0xFF);
        return ipAddr;
    }

    public static void main(String[] args) {
        String hexNum = "7f.00.00.01";
        String ipAddr = hexToIp(hexNum);
        System.out.println(ipAddr);
    }
}
PHP
function hexToIp($hexNum) {
    $hexNum = str_replace(".", "", $hexNum);
    $hexNum = str_replace("0x", "", $hexNum);
    $hexNum = str_pad($hexNum, 8, "0", STR_PAD_LEFT);
    $intNum = hexdec($hexNum);
    $byteArr = array(0, 0, 0, 0);
    $byteArr[0] = ($intNum & 0xFF000000) >> 24;
    $byteArr[1] = ($intNum & 0x00FF0000) >> 16;
    $byteArr[2] = ($intNum & 0x0000FF00) >> 8;
    $byteArr[3] = $intNum & 0x000000FF;
    $ipAddr = $byteArr[0] . "." . $byteArr[1] . "." . $byteArr[2] . "." . $byteArr[3];
    return $ipAddr;
}

$hexNum = "7f.00.00.01";
$ipAddr = hexToIp($hexNum);
echo $ipAddr;
Kotlin
fun hexToIp(hexNum: String): String {
    var hexNum = hexNum.replace(".", "")
    hexNum = hexNum.replace("0x", "")
    hexNum = hexNum.padStart(8, '0')
    val intNum = hexNum.toInt(16)
    val byteArr = ByteArray(4)
    byteArr[0] = (intNum and 0xFF000000.toInt()) ushr 24
    byteArr[1] = (intNum and 0x00FF0000) ushr 16
    byteArr[2] = (intNum and 0x0000FF00) ushr 8
    byteArr[3] = intNum and 0x000000FF
    val ipAddr = "${byteArr[0].toInt() and 0xFF}.${byteArr[1].toInt() and 0xFF}.${byteArr[2].toInt() and 0xFF}.${byteArr[3].toInt() and 0xFF}"
    return ipAddr
}

fun main() {
    val hexNum = "7f.00.00.01"
    val ipAddr = hexToIp(hexNum)
    println(ipAddr)
}

Conclusion

Convertir des nombres hexadécimaux en adresses IP ne doit pas être un processus difficile ou chronophage. Avec cet outil de conversion hex vers IP, vous pouvez rapidement et facilement convertir n'importe quel nombre hexadécimal en adresse IP. Que vous soyez développeur ou simplement quelqu'un qui a besoin de convertir des nombres hexadécimaux en adresses IP, cet outil est pour vous. Essayez-le dès aujourd'hui et voyez à quel point il est facile à utiliser !

Foire aux questions (FAQ)

Découvrez nos autres outils