javascript only implementation for encrypt and decrypt messages