Skip to content

Instantly share code, notes, and snippets.

@ProMPT120
Created October 30, 2018 00:29
Show Gist options
  • Save ProMPT120/d4595093e2be60c6c6ed95e2eb32de12 to your computer and use it in GitHub Desktop.
Save ProMPT120/d4595093e2be60c6c6ed95e2eb32de12 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"encoding/hex"
"fmt"
)
func main() {
encKey, err := hex.DecodeString("4e9906e8fcb66cc9faf49310620ffee8f496e806cc057990209b09a433b66c1b")
// Appropriate null iv as 0 ^ a = a
iv, err := hex.DecodeString("00000000000000000000000000000000")
ciphertext, err := base64.StdEncoding.DecodeString("PCXrmCkYWyRRx3bf+zqEydW9/trbFToMDx6fAvmeCDw=")
if err != nil {
panic(err)
}
block, err := aes.NewCipher([]byte(encKey))
if err != nil {
panic(err)
}
if len(ciphertext)%aes.BlockSize != 0 {
panic("ciphertext is not a multiple of the block size")
}
mode := cipher.NewCBCDecrypter(block, []byte(iv))
mode.CryptBlocks(ciphertext, ciphertext)
fmt.Printf("%s\n", ciphertext)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment