Skip to content

Crypto

AES encryption/decryption, HMAC, JWT tokens, and secure random generation.

7 modules

ModuleDescription
OdszyfrujOdszyfruj dane za pomocą szyfrowania AES
ZaszyfrujZaszyfruj dane za pomocą szyfrowania AES
HMACGenerate HMAC signature
Utwórz JWTUtwórz podpisany token JWT
Zweryfikuj JWTZweryfikuj i zdekoduj token JWT
Random BytesGenerate cryptographically secure random bytes
Random StringGenerate cryptographically secure random string

Modules

Odszyfruj

crypto.decrypt

Odszyfruj dane za pomocą szyfrowania AES

Parameters:

NameTypeRequiredDefaultDescription
ciphertextstringYes-Zaszyfrowane dane do odszyfrowania
keystringYes-Klucz szyfrowania
modeselect (CBC, GCM)NoGCMTryb szyfru AES (CBC, GCM, itp.)
input_formatselect (base64, hex)Nobase64Format wejściowego tekstu zaszyfrowanego (hex lub base64)

Output:

FieldTypeDescription
plaintextstringOdszyfrowany tekst jawny
algorithmstringAlgorytm użyty do odszyfrowania

Example: Decrypt AES-GCM ciphertext

yaml
ciphertext: <base64-encoded-ciphertext>
key: my-secret-passphrase
mode: GCM

Zaszyfruj

crypto.encrypt

Zaszyfruj dane za pomocą szyfrowania AES

Parameters:

NameTypeRequiredDefaultDescription
plaintextstringYes-Dane do zaszyfrowania
keystringYes-Klucz szyfrowania
modeselect (CBC, GCM)NoGCMTryb szyfru AES (CBC, GCM, itp.)
output_formatselect (base64, hex)Nobase64Format wyjściowego tekstu zaszyfrowanego (hex lub base64)

Output:

FieldTypeDescription
ciphertextstringZaszyfrowany tekst zaszyfrowany
algorithmstringAlgorytm użyty do szyfrowania
modestringUżyty tryb szyfru

Example: Encrypt with AES-GCM

yaml
plaintext: Hello, World!
key: my-secret-passphrase
mode: GCM

HMAC

crypto.hmac

Generate HMAC signature

Parameters:

NameTypeRequiredDefaultDescription
messagestringYes-Message to sign
keystringYes-Message to sign
algorithmselect (sha256, sha512, sha1, md5)Nosha256Secret key for HMAC
encodingselect (hex, base64)NohexOutput encoding format

Output:

FieldTypeDescription
signaturestringOutput encoding format
algorithmstringHMAC signature

Utwórz JWT

crypto.jwt_create

Utwórz podpisany token JWT

Parameters:

NameTypeRequiredDefaultDescription
payloadobjectYes-Dane ładunku JWT (obiekt)
secretstringYes-Klucz tajny do podpisania tokenu
algorithmselect (HS256, HS384, HS512, RS256)NoHS256Algorytm podpisania JWT (HS256, RS256, itp.)
expires_innumberNo-Czas wygaśnięcia tokenu w sekundach
issuerstringNo-Nadawca tokenu
audiencestringNo-Docelowi odbiorcy tokenu

Output:

FieldTypeDescription
tokenstringWygenerowany token JWT
algorithmstringAlgorytm użyty do podpisania
expires_atstringZnacznik czasu wygaśnięcia tokenu

Example: Create a JWT with expiration

yaml
payload: {"sub": "user123", "role": "admin"}
secret: my-jwt-secret
algorithm: HS256
expires_in: 3600

Zweryfikuj JWT

crypto.jwt_verify

Zweryfikuj i zdekoduj token JWT

Parameters:

NameTypeRequiredDefaultDescription
tokenstringYes-Token JWT do weryfikacji
secretstringYes-Klucz tajny używany do podpisania tokena
algorithmsarrayNo['HS256']Dozwolone algorytmy podpisania
verify_expbooleanNoTrueCzy weryfikować roszczenie o wygaśnięciu
audiencestringNo-Oczekiwany odbiorca
issuerstringNo-Oczekiwane roszczenie wydawcy

Output:

FieldTypeDescription
validbooleanCzy token jest ważny
payloadobjectZdekodowany ładunek JWT
headerobjectDane nagłówka JWT

Example: Verify a JWT token

yaml
token: eyJhbGciOiJIUzI1NiIs...
secret: my-jwt-secret
algorithms: ["HS256"]
verify_exp: true

Random Bytes

crypto.random_bytes

Generate cryptographically secure random bytes

Parameters:

NameTypeRequiredDefaultDescription
lengthnumberYes32Number of bytes
encodingstringNohexOutput encoding

Output:

FieldTypeDescription
bytesstringRandom bytes (encoded)
lengthnumberRandom bytes (encoded)

Random String

crypto.random_string

Generate cryptographically secure random string

Parameters:

NameTypeRequiredDefaultDescription
lengthnumberYes16String length
charsetstringNoalphanumericCharacters to use
uppercasebooleanNoFalseConvert to uppercase

Output:

FieldTypeDescription
stringstringConvert to uppercase
lengthnumberRandom string

Released under the Apache 2.0 License.