A self hosted chat application with end-to-end encrypted messaging.
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.

13 lines
643 B

  1. import { EncryptionService } from "./EncryptionService";
  2. import * as sjcl from "sjcl";
  3. export class SJCLEncryptionService implements EncryptionService {
  4. private readonly params: any = { mode: "gcm", ts: 128, adata: "", iter: 10000}
  5. public encrypt(passphrase: string, plainText: string): Object {
  6. return sjcl.encrypt(passphrase, plainText, this.params);
  7. }
  8. public decrypt(passphrase: string, cipher: Object): Object {
  9. // return sjcl.decrypt(passphrase, cipher as sjcl.SjclCipherEncrypted, undefined, undefined);
  10. return sjcl.decrypt(passphrase, JSON.stringify(cipher), undefined, undefined);
  11. }
  12. }