func TestColourValuesDifference(t *testing.T) {
	t.Parallel()
	SetLoggingLevel(logging.Level(*loggingLevel))

	// Load clean image
	var cleanImg StegImage
	err := cleanImg.LoadImageFromFile(cleanImageFile)
	if err != nil {
		t.Error(err)
	}

	// Embed secret
	err = cleanImg.DoStegEmbed(secretStringIn)
	if err != nil {
		t.Error(err)
	}

	// Create tmp file
	tmpTampered, err := ioutil.TempFile("", "")
	if err != nil {
		t.Error(err)
	}
	defer os.Remove(tmpTampered.Name())

	// Write manipulated image to file
	err = cleanImg.WriteNewImageToFile(tmpTampered.Name())
	if err != nil {
		t.Error(err)
	}

	var tamperedImg StegImage
	// Read it back in
	err = tamperedImg.LoadImageFromFile(tmpTampered.Name())
	if err != nil {
		t.Error(err)
	}

	// Check that the first n rgb values are only +1/-1 difference at most
	bounds := cleanImg.imgLoaded.Bounds()
	for x := bounds.Min.X; x < bounds.Max.X; x++ {
		for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
			r1, g1, b1, _ := cleanImg.imgLoaded.At(x, y).RGBA()
			r2, g2, b2, _ := tamperedImg.imgLoaded.At(x, y).RGBA()
			if err := checkColourDifference(uint8(r1), uint8(r2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
			if err := checkColourDifference(uint8(g1), uint8(g2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
			if err := checkColourDifference(uint8(b1), uint8(b2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
		}
	}
}
// TestColourValuesDifference validates that the tampered image
// colour values are in the acceptable range for LSB steganography (0,1,-1)
TestColourValuesDifference validates that the tampered image
colour values are in the acceptable range for LSB steganography (0,1,-1)
// TestColourValuesDifference validates that the tampered image // colour values are in the acceptable range for LSB steganography ( 0 1 - 1 )
func TestColourValuesDifference(t *testing.T) {
	t.Parallel()
	SetLoggingLevel(logging.Level(*loggingLevel))
	var cleanImg StegImage
	err := cleanImg.LoadImageFromFile(cleanImageFile)
	if err != nil {
		t.Error(err)
	}
	err = cleanImg.DoStegEmbed(secretStringIn)
	if err != nil {
		t.Error(err)
	}
	tmpTampered, err := ioutil.TempFile("", "")
	if err != nil {
		t.Error(err)
	}
	defer os.Remove(tmpTampered.Name())
	err = cleanImg.WriteNewImageToFile(tmpTampered.Name())
	if err != nil {
		t.Error(err)
	}
	var tamperedImg StegImage
	err = tamperedImg.LoadImageFromFile(tmpTampered.Name())
	if err != nil {
		t.Error(err)
	}
	bounds := cleanImg.imgLoaded.Bounds()
	for x := bounds.Min.X; x < bounds.Max.X; x++ {
		for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
			r1, g1, b1, _ := cleanImg.imgLoaded.At(x, y).RGBA()
			r2, g2, b2, _ := tamperedImg.imgLoaded.At(x, y).RGBA()
			if err := checkColourDifference(uint8(r1), uint8(r2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
			if err := checkColourDifference(uint8(g1), uint8(g2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
			if err := checkColourDifference(uint8(b1), uint8(b2)); err != nil {
				t.Log(err)
				t.FailNow()
			}
		}
	}
}
func TestColourValuesDifference ( t * testing . T ) { t . Parallel ( ) SetLoggingLevel ( logging . Level ( * loggingLevel ) ) var cleanImg StegImage err := cleanImg . LoadImageFromFile ( cleanImageFile ) if err != nil { t . Error ( err ) } err = cleanImg . DoStegEmbed ( secretStringIn ) if err != nil { t . Error ( err ) } tmpTampered , err := ioutil . TempFile ( " " , " " ) if err != nil { t . Error ( err ) } defer os . Remove ( tmpTampered . Name ( ) ) err = cleanImg . WriteNewImageToFile ( tmpTampered . Name ( ) ) if err != nil { t . Error ( err ) } var tamperedImg StegImage err = tamperedImg . LoadImageFromFile ( tmpTampered . Name ( ) ) if err != nil { t . Error ( err ) } bounds := cleanImg . imgLoaded . Bounds ( ) for x := bounds . Min . X ; x < bounds . Max . X ; x ++ { for y := bounds . Min . Y ; y < bounds . Max . Y ; y ++ { r1 , g1 , b1 , _ := cleanImg . imgLoaded . At ( x , y ) . RGBA ( ) r2 , g2 , b2 , _ := tamperedImg . imgLoaded . At ( x , y ) . RGBA ( ) if err := checkColourDifference ( uint8 ( r1 ) , uint8 ( r2 ) ) ; err != nil { t . Log ( err ) t . FailNow ( ) } if err := checkColourDifference ( uint8 ( g1 ) , uint8 ( g2 ) ) ; err != nil { t . Log ( err ) t . FailNow ( ) } if err := checkColourDifference ( uint8 ( b1 ) , uint8 ( b2 ) ) ; err != nil { t . Log ( err ) t . FailNow ( ) } } } }
TestColourValuesDifference validates that the tampered image
colour values are in the acceptable range for LSB steganography (0,1,-1)
TestColourValuesDifference validates that the tampered image colour values are in the acceptable range for LSB steganography ( 0 1 - 1 )
// Load clean image // Embed secret // Create tmp file // Write manipulated image to file // Read it back in // Check that the first n rgb values are only +1/-1 difference at most