mkdir -p work/src/my_project/aes
nano work/src/my_project/aes/aes.go
In nano, enter this code,
as shown below.
package main
import ( "crypto/aes"; "fmt" )
func main() {
plaintext := []byte("Hi There, World!")
key := []byte("1234567812345678")
cipher, _ := aes.NewCipher(key)
ciphertext := make([]byte, 16)
cipher.Encrypt(ciphertext, plaintext)
fmt.Printf("Ciphertext: %x\n", ciphertext)
decrypted := []byte("----------------")
cipher.Decrypt(decrypted, ciphertext)
fmt.Printf("Decrypted: %s\n", decrypted)
}
Save the file with
Ctrl+X, Y,
Enter.
Execute these commands to compile the program and run it:
go install my_project/aes
aes
The program runs,
printing out the encrypted ciphertext
and the decrypted string,
as shown below.
100 RED BALLOONSWith this key:
WWWWXXXXYYYYZZZZThe flag is the ciphertext in hexadecimal notation.
ab520094713cdf6bcd3ba5c82ce7f922With this key:
SUPER_SECRET_KEYThe flag is the plaintext.
Hint: How to transfer hex strings to []byte directly in Go?
e9aed443f53e8fdf827017838c33238984c7f7e171aff95c
2c74c08ce79ce58114a08d334b2491fbed64bed452d0e179
81be2fca01f11905c653f1bc6a73d321248e75bdc4eb96f4
3b50613a309377fb0443d78902b105ec57d3d03d4dac342d
0d52eacef350673a0e2e1ef32bf2352f4413489e48a4f9ae
495b2838e4dd23a0
With this key:
SIXTEEN_LETTERS!The flag is found at the end of the plaintext.
Hint: you need to decrypt each 16-byte block separately, as shown here:
With this key:
Sixteen_Letters!The flag is readable in the decrypted image.