detect not only str but also bytes
change generation of nonce