summaryrefslogtreecommitdiff
path: root/sha1.h
diff options
context:
space:
mode:
authorDmitry Ilyin <dima@doty.ru>2022-09-12 22:16:56 +0300
committerGitHub <noreply@github.com>2022-09-12 22:16:56 +0300
commite8313084f9e8b064433cb10eb9a79bf87407fab6 (patch)
tree9a98db8cb69dc07017512e0f28f9eb9bfe3b3a5c /sha1.h
parentbb41229ff4dbd62084994c6b0b2052a321fd0ccf (diff)
downloadlibevent-e8313084f9e8b064433cb10eb9a79bf87407fab6.tar.gz
Add minimal WebSocket server implementation for evhttp (#1322)
This adds few functions to use evhttp-based webserver to handle incoming WebSockets connections. We've tried to use both libevent and libwebsockets in our application, but found that we need to have different ports at the same time to handle standard HTTP and WebSockets traffic. This change can help to stick only with libevent library. Implementation was inspired by modified Libevent source code in ipush project [1]. [1]: https://github.com/sqfasd/ipush/tree/master/deps/libevent-2.0.21-stable Also, WebSocket-based chat server was added as a sample.
Diffstat (limited to 'sha1.h')
-rw-r--r--sha1.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/sha1.h b/sha1.h
new file mode 100644
index 00000000..1accbc77
--- /dev/null
+++ b/sha1.h
@@ -0,0 +1,28 @@
+#ifndef SHA1_H
+#define SHA1_H
+
+/*
+ SHA-1 in C
+ By Steve Reid <steve@edmweb.com>
+ 100% Public Domain
+ */
+
+#include "stdint.h"
+
+typedef struct {
+ uint32_t state[5];
+ uint32_t count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
+
+void SHA1Init(SHA1_CTX *context);
+
+void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len);
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
+
+void SHA1(char *hash_out, const char *str, int len);
+
+#endif /* SHA1_H */