We added $toHashedIndexKey in
SERVER-49214 which solves some similar use cases, and some described below in the original description and comments. This ticket remains open to add a more general hash expression - perhaps for more cryptographic use cases, or if someone wants/needs a particular algorithm.
Oracle has http://docs.oracle.com/database/121/SQLRF/functions183.htm#SQLRF55647 which computes one of several standard hash functions on a particular column.
It would be nice if there was analogous expression in agg:
or something like that.