I'm thinking of a generic approach which is independent of where you got the secret key and its format.