fix broken encrypt in localstorage
fixes
rm log
add preconditions
Merge pull request #2148 from matiu/bug/encrypt-localstorage

Bug/encrypt localstorage