a crypto helper function