| name | fle-scala |
| summary | Field-Level Encryption is not supported by the Couchbase Scala SDK — alternatives and workarounds |
| description | Field-Level Encryption is not supported by the Couchbase Scala SDK — alternatives and workarounds |
| compatibility | Scala SDK 1.x. FLE not supported. |
| metadata | {"last_verified":"2026-05","handoff":[{"condition":"user asks about FLE concepts or supported SDKs","skill":"fle"},{"condition":"user asks about server-side encryption at rest","skill":"security"}]} |
Field-Level Encryption — Scala
The Couchbase Scala SDK does not support Field-Level Encryption. There is no CryptoManager API.
Alternatives
Option 1 — Encrypt in application code before writing:
import javax.crypto.{Cipher, SecretKey}
import javax.crypto.spec.{GCMParameterSpec, SecretKeySpec}
import java.util.Base64
def encrypt(plaintext: String, key: SecretKey): String = {
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
val iv = new Array[Byte](12)
new java.security.SecureRandom().nextBytes(iv)
cipher.init(Cipher.ENCRYPT_MODE, key, new GCMParameterSpec(128, iv))
val ciphertext = cipher.doFinal(plaintext.getBytes("UTF-8"))
Base64.getEncoder.encodeToString(iv ++ ciphertext)
}
val doc = ujson.Obj(
"name" -> "Alice",
"ssn" -> encrypt("123-45-6789", secretKey) // store ciphertext
)
collection.upsert("user::alice", doc).get
Option 2 — Use the Java SDK from Scala:
The Java SDK supports FLE via @Encrypted. You can use it from Scala by depending on couchbase-java and couchbase-encryption directly. See fle-java.
Option 3 — Server-side encryption at rest (Couchbase Server 8.x):
See the security skill.