added nonce func and encoded a string