LV. Mcrypt Encryption Functions
דוגמה
1
.
?php
$key
=
"
this
is
a
very
secret
key"
;
$input
=
"Let
us
meet
at
9
o'clock
at
the
secret
place
."
;
$encrypted_data
=
mcrypt_ecb
(MCRYPT_3DES
,
$key
,
$input
,
MCRYPT_ENCRYPT)
;
?
|
|
This example will give you the encrypted data as a string in
$encrypted_data
.
דוגמה
2
.
?php
$key
=
"
this
is
a
very
secret
key"
;
$input
=
"Let
us
meet
at
9
o'clock
at
the
secret
place
."
;
$td
=
mcrypt_module_open
('tripledes'
,
''
,
'ecb'
,
'')
;
$iv
=
mcrypt_create_iv
(mcrypt_enc_get_iv_size
($td)
,
MCRYPT_RAND)
;
mcrypt_generic_init
($td
,
$key
,
$iv)
;
$encrypted_data
=
mcrypt_generic
($td
,
$input)
;
mcrypt_generic_end
($td)
;
?
|
|
This example will give you the encrypted data as a string in
$encrypted_data
. For a full example see
mcrypt_module_open()
.
To
use
it
,
download
libmcrypt-x.x.tar.gz
from
here
To
use
it
,
download
libmcrypt-x.x.tar.gz
from
here
and
follow
the
included
installation
instructions
.
You
need
to
compile
PHP
with
the
--with-mcrypt
parameter
to
enable
this
extension
.
This
extension
does
not
define
any
resource
types
.