Say I have an IP address, 192.168.1.1
I want my program to create a random one-word string based on this IP address which can be easily decrypted without a key or password or additional security.
I enter 192.168.1.1
Program converts it to AzlQrEHCSD or some other random string
I enter this string in the program
It gets converted back to 192.168.1.1
I know its overkill but i would use jasypt library since its realy easy to use. All you need is random seed to encrypt or decrpyt.
Here is the source code for encrypting data:
String seed = "ipNumber"; String myIpValue = "192.168.0.1"; StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(seed); String encrypted= encryptor.encrypt(myIpValue);
And for data decryption:
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(seed); String decrypted = encryptor.decrypt(encrypted);
Or you could just encode or decode your string to base64 example is show here: Base64 Java encode and decode a string