YOUSEFUL / FILEMAKER

YsflCrypt functions (v1.0.0)

FAQ, examples and tutorial

All cryptography uses Windows CNG. A failing call returns ? message and sets YsflCr_LastError / YsflCr_LastErrorText. Options are space-separated tokens. Containers are accepted as container parameters and returned as containers with a file name.

Plugin

Function Returns
YsflCr_Version YsflCrypt v.1.0.0
YsflCr_Register ( {option} ) Registered.
YsflCr_LastError / YsflCr_LastErrorText last failure code (1001 param, 1002 option, 1003 regex, 1004 encoding, 1005 xml, 1006 memory, 1007 crypto, 1008 I/O) and message

Password-based encryption

Options: aes128 (default AES-256), cbc (AES-CBC + PKCS7 for interop; default AES-GCM authenticated), iter=N (PBKDF2-HMAC-SHA256 iterations, default 600000, minimum 1000).

Function Description
YsflCr_Encrypt ( text ; password ; {options} ) returns a gfcr1: envelope (salt, nonce, tag and ciphertext in Base64)
YsflCr_Decrypt ( envelope ; password ) original text; ? Decryption failed on a wrong password or tampering
YsflCr_EncryptContainer ( container ; password ; {options} ) envelope holding the container's bytes, file name and type
YsflCr_DecryptToContainer ( envelope ; password ; {fileName} ) container restored with its original name, or renamed

Explicit key material (interop)

Function Description
YsflCr_DeriveKey ( passphrase ; salt ; {options} ) two lines: Base64 key and Base64 IV from PBKDF2-HMAC-SHA256 (iter=N default 10000, aes128)
YsflCr_EncryptWithKey ( text ; keyBase64 ; ivBase64 ; {options} ) Base64 ciphertext; AES-CBC/PKCS7 by default (matches OpenSSL enc -nosalt), nopad zero padding, gcm with the tag appended and a 12-byte IV
YsflCr_DecryptWithKey ( base64 ; keyBase64 ; ivBase64 ; {options} ) text

Digests

Function Description
YsflCr_Digest ( text ; {algorithm} ; {encoding} ) sha256 (default), sha1, sha512, md5, crc32, fnv1a; hex (default), HEX, base32, base64, safe
YsflCr_HMAC ( text ; key ; {algorithm} ; {encoding} ) keyed digest (sha256 default, sha1, sha512, md5)
YsflCr_Signature ( text ) 24-character change-detection signature ignoring case, whitespace and punctuation

Containers and Base64

Function Description
YsflCr_ContainerToBase64 ( container ) Base64 of the container's main stream
YsflCr_Base64ToContainer ( base64 ; fileName ) container; type from the extension (png, jpg, gif, bmp, pdf, else generic file)
YsflCr_ContainerFileName ( container ) the stored file name

Compression

Function Description
YsflCr_Compress ( text ; {level} ) gfz1: + Base64 zlib stream, level 1..9 (default 6)
YsflCr_Decompress ( text ) original text

Passwords and randomness

Function Description
YsflCr_GeneratePassword ( {length} ; {options} ) default 20 characters with a dash every 7; dashes=N, nodashes, symbols, nosimilar
YsflCr_PasswordStrength ( password ) 0..100 (length, character classes, repetition and sequence penalties, common-password list)
YsflCr_RandomBytes ( count ; {encoding} ) CSPRNG bytes as hex (default), base64 or safe
YsflCr_Rot13 ( text ) ROT13

Windows Credential Manager

Stored as generic credentials named Youseful:<name> for the current Windows user. Existing credentials from before the rebrand remain readable, updatable and deletable under their original storage names. New names use the Youseful namespace.

Function Description
YsflCr_CredentialSave ( name ; secret ; {options} ) 0; ? Credential exists unless overwrite
YsflCr_CredentialGet ( name ) the secret; ? Credential not found
YsflCr_CredentialDelete ( name ) 0; ? Credential not found