fixed bug in generating encrypted header key