Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php	(revision 6330)
+++ t3lib/class.t3lib_div.php	(working copy)
@@ -1090,6 +1090,18 @@
 	}
 
 	/**
+	 * Returns a variable length of a proper HMAC on a given
+	 * input string and secret TYPO3 encryption key.
+	 *
+	 * @param 	string		Input string to create HMAC from
+	 * @param 	integer		The maximum string-length of the output
+	 * @return 	string		Substring of the resulting HMAC, being at maximum $len chars long (from beginning)
+	 */
+	public static function hmac($input, $len=32) {
+		return substr(hash_hmac('md5', $input, $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']), 0, $len);
+	}
+
+	/**
 	 * Takes comma-separated lists and arrays and removes all duplicates
 	 * If a value in the list is trim(empty), the value is ignored.
 	 * Usage: 16
Index: tests/t3lib/t3lib_div_testcase.php
===================================================================
--- tests/t3lib/t3lib_div_testcase.php	(revision 6275)
+++ tests/t3lib/t3lib_div_testcase.php	(working copy)
@@ -651,6 +651,33 @@
 			t3lib_div::quoteJSvalue('\\')
 		);
 	}
+
+	/**
+	 * @test
+	 */
+	public function hmacReturnsHashOfProperLength() {
+		$hmac = t3lib_div::hmac('message', 32);
+		$this->assertTrue(is_string($hmac) && !empty($hmac));
+		$this->assertTrue(strlen($hmac) <= 32);
+	}
+
+	/**
+	 * @test
+	 */
+	public function hmacReturnsEqualHashesForEqualInput() {
+		$msg0 = 'message';
+		$msg1 = 'message';
+		$this->assertEquals(t3lib_div::hmac($msg0, 32), t3lib_div::hmac($msg1, 32));
+	}
+
+	/**
+	 * @test
+	 */
+	public function hmacReturnsNotEqualHashesForNotEqualInput() {
+		$msg0 = 'message0';
+		$msg1 = 'message1';
+		$this->assertNotEquals(t3lib_div::hmac($msg0, 32), t3lib_div::hmac($msg1, 32));
+	}
 }
 
 ?>
\ No newline at end of file