summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Component/ComponentHandshakeGenerator.cpp')
-rw-r--r--Swiften/Component/ComponentHandshakeGenerator.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/Swiften/Component/ComponentHandshakeGenerator.cpp b/Swiften/Component/ComponentHandshakeGenerator.cpp
new file mode 100644
index 0000000..422f986
--- /dev/null
+++ b/Swiften/Component/ComponentHandshakeGenerator.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/Component/ComponentHandshakeGenerator.h"
+#include "Swiften/StringCodecs/Hexify.h"
+#include "Swiften/StringCodecs/SHA1.h"
+
+namespace Swift {
+
+String ComponentHandshakeGenerator::getHandshake(const String& streamID, const String& secret) {
+ String concatenatedString = streamID + secret;
+ concatenatedString.replaceAll('&', "&");
+ concatenatedString.replaceAll('<', "&lt;");
+ concatenatedString.replaceAll('>', "&gt;");
+ concatenatedString.replaceAll('\'', "&apos;");
+ concatenatedString.replaceAll('"', "&quot;");
+ return Hexify::hexify(SHA1::getHash(ByteArray(concatenatedString)));
+}
+
+}