You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
643 B
14 lines
643 B
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);
|
|
}
|
|
}
|