Exemple #1
0
func TestDecryptAES_ECB_Manual(t *testing.T) {

	key := "YELLOW SUBMARINE"

	expetedText := "YELLOW SUBMARINE"
	expetedTextPadding := "YELLOW SUBMARINE!"

	cipherText := "d1aa4f6578926542fbb6dd876cd20508"
	cipherTextPadding := "d1aa4f6578926542fbb6dd876cd20508be02542eda8a4ae9cd80e9ce20751237"

	textBytes := secutils.HexStringToBytes(cipherText)
	text := DecryptAES_ECB_Manual(textBytes, []byte(key))
	if expetedText != secutils.BytesToASCIIString(text) {
		t.Error("Test Decrypt AES_ECB Manually FAILED !")
	}
	fmt.Printf("4. Test DecryptAES_ECB_Manual: %s\n", text)

	textBytesPadding := secutils.HexStringToBytes(cipherTextPadding)
	textPadding := DecryptAES_ECB_Manual(textBytesPadding, []byte(key))
	if expetedTextPadding != secutils.BytesToASCIIString(textPadding) {
		t.Error("Test Decrypt AES_ECB Manually + PADDING FAILED !")
	}
	fmt.Printf("4. Test DecryptAES_ECB_Manual + PADDING: %s\n", textPadding)

}
Exemple #2
0
//d7ab340a60337584edbab1a82d6b0977
func TestDecryptAES_CBC_Manual(t *testing.T) {
	text := secutils.HexStringToBytes("a6af0c64422b96e8923c1ebe819e82553e8e38f74e1693a9cde95502229ddcc0")
	key := secutils.ASCIIStringToBytes("YELLOW SUBMARINE")
	//cipherTextBytes, _ := DecryptAES_CBC(text, key)
	cipherTextBytes := DecryptAES_CBC_Manual(text, key)

	//cipherHex := secutils.BytesToHex(cipherTextBytes)
	fmt.Printf("6. Test DecryptAES_CBC Manual: %s\n", cipherTextBytes)
}