Fully end to end encrypted anonymous chat program. Server only stores public key lookup for users and the encrypted messages. No credentials are transfered to the server, but kept in local browser storage. This allows 100% safe chatting. https://safechat.ch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

10 years ago
<?php
10 years ago
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
10 years ago
/// Get a user's public key
/** Get the public key of a user.
10 years ago
@param $user Name of the user to ge public key from.
10 years ago
@return json encoded value:
- @c null in case of error (user does not exist)
- @code
{
pubkey: 'armored public key string'
}
@endcode
@api Get A User's Public Key
10 years ago
*/
function pubkey($user) {
try {
require_once("opendb.php");
$user = $db->real_escape_string($user);
$q = $db->query("select pubkey from user where name='$user';");
/* if ($q->num_rows!=1 && $user=="safechat") { */
/* require_once("optionstable.php"); */
/* createSafechatUser(); */
/* $q = $db->query("select pubkey from user where name='$user';"); */
/* } */
if ($q->num_rows==1) {
echo json_encode($q->fetch_row()[0]);
} else {
echo json_encode(null);
}
} catch (Exception $e) {
10 years ago
echo json_encode(null);
}
}
pubkey($_REQUEST['user']);
10 years ago
?>