I don't understand the question, please explain in more detail. Have you already implemented that function in a Function node or is that what you are asking how to do?
However, if it is your goal to learn how to implement somthing like this in node-red function then simply add a reference to crypto in the function setup like this: Use any npm module in Node-RED • FlowFuse