func CipherBytesFromPrimitives(plaintext []byte, singleLine,
	disableValidation bool,
	projectID, locationID, keyRingID, cryptoKeyID, keyName string,
	kmsProvider KmsProvider) (cipherBytes []byte) {

	dek := randByteSlice(dekLength)
	nonce := randByteSlice(nonceLength)
	encrypt := true
	encryptedDek, err := kmsProvider.crypto(dek, projectID, locationID, keyRingID,
		cryptoKeyID, keyName, encrypt)
	check(err)
	cipherBytes = []byte(base64.StdEncoding.EncodeToString(append(
		append(cipherText(plaintext, cipherblock(dek), nonce, encrypt),
			nonce...),
		encryptedDek...)))
	if !singleLine {
		cipherBytes = insertNewLines(cipherBytes)
	}
	if !disableValidation {
		//validate the ciphertext
		fmt.Println("Validating ciphertext")
		cipherString, err := base64.StdEncoding.DecodeString(string(cipherBytes))
		check(err)
		_, err = PlainTextFromPrimitives(cipherString, projectID,
			locationID, keyRingID, cryptoKeyID, keyName, kmsProvider)
		check(err)
	}
	return
}
//CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes
CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes
// CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes
func CipherBytesFromPrimitives(plaintext []byte, singleLine,
	disableValidation bool,
	projectID, locationID, keyRingID, cryptoKeyID, keyName string,
	kmsProvider KmsProvider) (cipherBytes []byte) {
	dek := randByteSlice(dekLength)
	nonce := randByteSlice(nonceLength)
	encrypt := true
	encryptedDek, err := kmsProvider.crypto(dek, projectID, locationID, keyRingID,
		cryptoKeyID, keyName, encrypt)
	check(err)
	cipherBytes = []byte(base64.StdEncoding.EncodeToString(append(
		append(cipherText(plaintext, cipherblock(dek), nonce, encrypt),
			nonce...),
		encryptedDek...)))
	if !singleLine {
		cipherBytes = insertNewLines(cipherBytes)
	}
	if !disableValidation {
		fmt.Println("Validating ciphertext")
		cipherString, err := base64.StdEncoding.DecodeString(string(cipherBytes))
		check(err)
		_, err = PlainTextFromPrimitives(cipherString, projectID,
			locationID, keyRingID, cryptoKeyID, keyName, kmsProvider)
		check(err)
	}
	return
}
func CipherBytesFromPrimitives ( plaintext [ ] byte , singleLine , disableValidation bool , projectID , locationID , keyRingID , cryptoKeyID , keyName string , kmsProvider KmsProvider ) ( cipherBytes [ ] byte ) { dek := randByteSlice ( dekLength ) nonce := randByteSlice ( nonceLength ) encrypt := true encryptedDek , err := kmsProvider . crypto ( dek , projectID , locationID , keyRingID , cryptoKeyID , keyName , encrypt ) check ( err ) cipherBytes = [ ] byte ( base64 . StdEncoding . EncodeToString ( append ( append ( cipherText ( plaintext , cipherblock ( dek ) , nonce , encrypt ) , nonce ... ) , encryptedDek ... ) ) ) if ! singleLine { cipherBytes = insertNewLines ( cipherBytes ) } if ! disableValidation { fmt . Println ( " " ) cipherString , err := base64 . StdEncoding . DecodeString ( string ( cipherBytes ) ) check ( err ) _ , err = PlainTextFromPrimitives ( cipherString , projectID , locationID , keyRingID , cryptoKeyID , keyName , kmsProvider ) check ( err ) } return }
CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes
CipherBytesFromPrimitives encrypts plaintext bytes and returns ciphertext bytes
//validate the ciphertext