import { EncryptionService } from "./EncryptionService"; import * as sjcl from "sjcl"; export class SJCLEncryptionService implements EncryptionService { private readonly params: any = { mode: "gcm", ts: 128, adata: "", iter: 10000} public encrypt(passphrase: string, plainText: string): Object { return sjcl.encrypt(passphrase, plainText, this.params); } public decrypt(passphrase: string, cipher: Object): Object { // return sjcl.decrypt(passphrase, cipher as sjcl.SjclCipherEncrypted, undefined, undefined); return sjcl.decrypt(passphrase, JSON.stringify(cipher), undefined, undefined); } }