fix indexing in crypting bug