Function which returns HMAC-SHA1 encrypted signature composed of public key and secret base string:
- {
- int blockSize = 64; // HMAC-SHA-1 block size, defined in SHA-1 standard
- if (key.length() > blockSize) { // if key is longer than block size (64), reduce key length with SHA-1 compression
- }
- // ascii characters 0x36 ("6") and 0x5c ("\") are selected because they have large
- // Hamming distance (http://en.wikipedia.org/wiki/Hamming_distance)
- for (int i = 0; i < key.length(); i++) {
- innerPadding[i] = innerPadding[i] ^ key.at(i); // XOR operation between every byte in key and innerpadding, of key length
- outerPadding[i] = outerPadding[i] ^ key.at(i); // XOR operation between every byte in key and outerpadding, of key length
- }
- // result = hash ( outerPadding CONCAT hash ( innerPadding CONCAT baseString ) ).toBase64
- part.append(baseString);
- return hashed.toBase64();
- }

