💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Class **Phalcon\Crypt**[](# "永久链接至标题") *implements*[*Phalcon\CryptInterface*](#) Provides encryption facilities to phalcon applications ~~~ <?php $crypt = new \Phalcon\Crypt(); $key = 'le password'; $text = 'This is a secret text'; $encrypted = $crypt->encrypt($text, $key); echo $crypt->decrypt($encrypted, $key); ~~~ ### Constants[](# "永久链接至标题") *integer***PADDING_DEFAULT** *integer***PADDING_ANSI_X_923** *integer***PADDING_PKCS7** *integer***PADDING_ISO_10126** *integer***PADDING_ISO_IEC_7816_4** *integer***PADDING_ZERO** *integer***PADDING_SPACE** ### Methods[](# "永久链接至标题") public **setPadding** (*int* $scheme) Changes the padding scheme used public **setCipher** (*unknown* $cipher) Sets the cipher algorithm public **getCipher** () Returns the current cipher public **setMode** (*unknown* $mode) Sets the encrypt/decrypt mode public **getMode** () Returns the current encryption mode public **setKey** (*unknown* $key) Sets the encryption key public **getKey** () Returns the encryption key protected **_cryptPadText** (*unknown* $text, *unknown* $mode, *unknown* $blockSize, *unknown* $paddingType) Pads texts before encryption protected **_cryptUnpadText** (*unknown* $text, *unknown* $mode, *unknown* $blockSize, *unknown* $paddingType) If the function detects that the text was not padded, it will return it unmodified public **encrypt** (*unknown* $text, [*unknown* $key]) Encrypts a text ~~~ <?php $encrypted = $crypt->encrypt("Ultra-secret text", "encrypt password"); ~~~ public **decrypt** (*unknown* $text, [*unknown* $key]) Decrypts an encrypted text ~~~ <?php echo $crypt->decrypt($encrypted, "decrypt password"); ~~~ public **encryptBase64** (*unknown* $text, [*unknown* $key], [*unknown* $safe]) Encrypts a text returning the result as a base64 string public **decryptBase64** (*unknown* $text, [*unknown* $key], [*unknown* $safe]) Decrypt a text that is coded as a base64 string public **getAvailableCiphers** () Returns a list of available cyphers public **getAvailableModes** () Returns a list of available modes | - [索引](# "总目录") - [下一页](# "Class Phalcon\Crypt\Exception") | - [上一页](# "Class Phalcon\Config\Exception") | - [API Indice](#) »