MCPcopy Create free account
hub / github.com/acl-dev/acl / create_ws_key

Method create_ws_key

lib_acl_cpp/src/http/http_header.cpp:1186–1212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184}
1185
1186unsigned char* http_header::create_ws_key(const void* key, size_t len) const
1187{
1188 string tmp(key, len);
1189 tmp += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
1190
1191 sha1 sha;
1192 sha.input(tmp.c_str(), (unsigned int) tmp.size());
1193 unsigned char digest[20];
1194 sha.result2((unsigned*) digest);
1195 //sha.result((unsigned char*) digest);
1196
1197 //little endian to big endian
1198 for (int i = 0; i < 20; i += 4) {
1199 unsigned char c;
1200
1201 c = digest[i];
1202 digest[i] = digest[i + 3];
1203 digest[i + 3] = c;
1204
1205 c = digest[i + 1];
1206 digest[i + 1] = digest[i + 2];
1207 digest[i + 2] = c;
1208 }
1209
1210 unsigned char* s = acl_base64_encode((char*) digest, 20);
1211 return s;
1212}
1213
1214bool http_header::build_response(string& out) const
1215{

Callers

nothing calls this directly

Calls 5

acl_base64_encodeFunction · 0.85
inputMethod · 0.80
result2Method · 0.80
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected