summaryrefslogtreecommitdiffstats
path: root/challenge/c18.go
blob: a84776ea9b8e556243a06dc7c9450795f53d183d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright © 2021 rsiddharth <s@ricketyspace.net>
// SPDX-License-Identifier: ISC

package challenge

import (
	"fmt"

	"ricketyspace.net/cryptopals/lib"
)

// Cryptopals #18 - Implement CTR, the stream cipher mode
func C18() {
	cipher := lib.Base64ToBytes("L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ==")
	key := lib.StrToBytes("YELLOW SUBMARINE")
	ctrFunc := lib.AESGenCTRFunc(0)
	plain, err := lib.AESDecryptCTR(cipher, key, ctrFunc)
	if err != nil {
		fmt.Printf("decryption failed: %v", err)
	}
	fmt.Printf("%v\n", lib.BytesToStr(plain))
}

// Output:
// Yo, VIP Let's kick it Ice, Ice, baby Ice, Ice, baby