The value to check
Optional encryptionMarker: stringOptional custom encryption marker prefix. If not provided, uses the default $ENC$.
This allows for per-key markers as defined in the EncryptionKey entity's Marker field.
True if the value is the encrypted sentinel or starts with the encryption marker, false otherwise
import { IsValueEncrypted, ENCRYPTION_MARKER } from '@memberjunction/global';
const encrypted = '$ENC$keyId$AES-256-GCM$iv$ciphertext$authTag';
const customEncrypted = '$CUSTOM$keyId$AES-256-GCM$iv$ciphertext';
const sentinel = '[!ENCRYPTED$]';
const plaintext = 'Hello World';
console.log(IsValueEncrypted(encrypted)); // true
console.log(IsValueEncrypted(sentinel)); // true
console.log(IsValueEncrypted(customEncrypted, '$CUSTOM$')); // true
console.log(IsValueEncrypted(plaintext)); // false
console.log(IsValueEncrypted(null)); // false
console.log(IsValueEncrypted('')); // false
Checks if a string value is encrypted or is the encrypted sentinel.
This function returns true if the value:
[!ENCRYPTED$]), indicating a protected value not disclosed to the client$ENC$or a custom marker if provided)