Skip to content

Commit 777958c

Browse files
authored
Merge pull request #24 from phillip-che/encryption-branch
2 parents fa7be03 + 71bb459 commit 777958c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

client/components/LoginFields.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { useSocket } from '@/context/socket.context';
1010
import { Divider } from '@mui/material';
1111

1212
const LoginFields = () => {
13-
const { socket, username, setUsername, roomID } = useSocket();
14-
const [usernameInput, setUsernameInput] = useState<string>('');
15-
const [roomIDInput, setRoomIDInput] = useState<string>('');
13+
14+
const { socket, setUsername, roomID } = useSocket();
15+
const [usernameInput, setUsernameInput] = useState<string>("");
16+
const [roomIDInput, setRoomIDInput] = useState<string>("");
1617

1718
const handleUsernameChange = (e: any) => {
1819
setUsernameInput(e.target.value);

client/context/socket.context.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { createContext, useContext, useState, useEffect, useRef } from 'react';
3+
import { createContext, useContext, useState, useEffect } from 'react';
44
import io, { Socket } from 'socket.io-client';
55
import EVENTS from '@/config/events';
66
import crypto from 'crypto'
@@ -22,16 +22,15 @@ interface Context {
2222
}
2323

2424
const SOCKET_URL =
25-
process.env.NEXT_PUBLIC_SOCKET_URL || 'https://cypherchat.lol:4000';
25+
process.env.NEXT_PUBLIC_SOCKET_URL || "http://localhost:4000";
2626

2727
const socket = io(SOCKET_URL, {
2828
reconnection: true,
2929
upgrade: true,
3030
transports: ['websocket', 'polling'],
3131
});
3232

33-
const aesKeyString = "fcba69ac69c7182417c68a5f6f78f6a24072156dd444013e69a2820f631164e7";
34-
const aesKey = Buffer.from(aesKeyString, 'hex');
33+
const aesKey = Buffer.from(process.env.NEXT_PUBLIC_AES_KEY_STRING as string, 'hex');
3534

3635
const SocketContext = createContext<Context>({
3736
socket,

server/src/app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ httpServer.listen(port, () => {
6262

6363
socket.on(EVENTS.CLIENT.SEND_MESSAGE, (data) => {
6464
console.log(`${data.username} sent a ${data.type} to room: ${data.roomID}`);
65-
65+
console.log(`Encrypted Message: ${data.body}`);
6666
socket.to(data.roomID).emit(EVENTS.SERVER.SEND_MESSAGE,
6767
{
6868
type: data.type,

0 commit comments

Comments
 (0)