Created
August 24, 2023 21:49
-
-
Save jedisct1/ce4fe6d670b781d00afea350578eb295 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/aes" | |
"net" | |
) | |
func EncryptIp(key []byte, ip net.IP) net.IP { | |
cipher, err := aes.NewCipher(key) | |
if err != nil { | |
panic(err) | |
} | |
encrypted_ip := ip.To16() | |
cipher.Encrypt(encrypted_ip, encrypted_ip) | |
return encrypted_ip | |
} | |
func main() { | |
key := []byte("example key 1234") // must be 16 bytes | |
ip := net.IPv4(93, 184, 216, 3) | |
encrypted_ip := EncryptIp(key, ip) | |
println(encrypted_ip.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment