@schiesbn isn't this something that you also did in some places in the encryption app ?
If yes, might be worth moving this to \OCP\Util ?