FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Salt/example/box.php at master · devi/Salt · GitHub
This repository was archived by the owner on May 8, 2019. It is now read-only.
devi
/
Salt
Public archive
Notifications
You must be signed in to change notification settings
Fork
8
Star
13
Code
Issues
5
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Salt
/
example
/
box.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (25 loc) · 877 Bytes
Breadcrumbs
Salt
/
example
/
box.php
Copy path
File metadata and controls
36 lines (25 loc) · 877 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include
"
../autoload.php
"
;
// alice generate key pair
$
alice
= Salt::
box_keypair
();
$
alice_privatekey
=
$
alice
[
0
];
$
alice_publickey
=
$
alice
[
1
];
// bob generate key pair
$
bob
= Salt::
box_keypair
();
$
bob_privatekey
=
$
bob
[
0
];
$
bob_publickey
=
$
bob
[
1
];
$
msg
=
'
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
'
;
// alice generate 24 byte nonce
$
nonce
= Salt::
randombytes
(
24
);
// alice encrypt the message using her private key, bob publickey and a nonce
$
chipertext
= Salt::
box
(
$
msg
,
$
alice_privatekey
,
$
bob_publickey
,
$
nonce
);
// bob decrypt the chipertext from alice using his private key, alice public key and
// a nonce received from alice
$
the_message
= Salt::
box_open
(
$
chipertext
,
$
bob_privatekey
,
$
alice_publickey
,
$
nonce
);
if
(!
$
the_message
) {
echo
'
This is a bug
'
;
}
else
{
// bob read the message
echo
$
the_message
->
toString
();
}
echo
"\n"
;
Back
|
FazBrowse Home
|
New Git URL