Package net.targetr.wtm3.io
Class IPCrypt
java.lang.Object
net.targetr.wtm3.io.IPCrypt
Implementation of ipcrypt-deterministic using AES-128.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbytesToHex(byte[] bytes) Convert byte array to hex string.static InetAddressbytesToIp(byte[] bytes16) Convert a 16-byte representation back to an IP address.static StringEncrypt an IP address using AES-128.static Stringencrypt(InetAddress ip, byte[] key) Encrypt an IP address using AES-128.static byte[]hexToBytes(String hex) Convert a hex string to byte array.static byte[]Convert an IP address to its 16-byte representation.static byte[]ipToBytes(InetAddress ip) Convert an IP address to its 16-byte representation.static voidUtility main method to decrypt an IP Address with a key.
-
Method Details
-
encrypt
Encrypt an IP address using AES-128.- Parameters:
ip- The IP address to encryptkey- 16-byte encryption key- Returns:
- Encrypted IP address
- Throws:
Exception- if encryption fails
-
encrypt
Encrypt an IP address using AES-128.- Parameters:
ip- The IP address to encryptkey- 16-byte encryption key- Returns:
- Encrypted IP address
- Throws:
Exception- if encryption fails
-
ipToBytes
Convert an IP address to its 16-byte representation.- Parameters:
ip- IP address as string- Returns:
- 16-byte representation
- Throws:
UnknownHostException- if IP address is invalid
-
ipToBytes
Convert an IP address to its 16-byte representation.- Parameters:
ip- IP address as InetAddress- Returns:
- 16-byte representation
-
bytesToIp
Convert a 16-byte representation back to an IP address.- Parameters:
bytes16- 16-byte representation- Returns:
- IP address as InetAddress
- Throws:
UnknownHostException- if byte array is invalid
-
hexToBytes
Convert a hex string to byte array.- Parameters:
hex- Hex string- Returns:
- Byte array
-
bytesToHex
Convert byte array to hex string.- Parameters:
bytes- Byte array- Returns:
- Hex string
-
main
Utility main method to decrypt an IP Address with a key. Note, the active RCWeb server can not do this.- Parameters:
args- Command line arguments of IP Address to decrypt and key- Throws:
Exception- a problem with the address or key
-