Rohan Sircar
4 years ago
5 changed files with 56 additions and 42 deletions
-
47src/main/frontend/chat/dto/MessageCipherDTO.ts
-
5src/main/frontend/chat/service/EncryptionServiceFactory.ts
-
16src/main/frontend/chat/service/SJCLEncryptionService.ts
-
5src/main/frontend/common/model/ChatModelHelper.ts
-
3src/main/frontend/workers/encryption-worker/main.ts
@ -1,27 +1,40 @@ |
|||||
export class MessageCipherDTO { |
|
||||
|
// export class MessageCipherDTO {
|
||||
|
// // iv!: string;
|
||||
|
// // v!: number;
|
||||
|
// // iterations!: number;
|
||||
|
// // keySize!: number;
|
||||
|
// // tagSize!: number;
|
||||
|
// // mode!: string;
|
||||
|
// // adata!: string;
|
||||
|
// // cipher!: string;
|
||||
|
// // salt!: string;
|
||||
|
// // cipherText!: string;
|
||||
|
|
||||
// iv!: string;
|
// iv!: string;
|
||||
// v!: number;
|
// v!: number;
|
||||
// iterations!: number;
|
|
||||
// keySize!: number;
|
|
||||
// tagSize!: number;
|
|
||||
|
// iter!: number;
|
||||
|
// ks!: number;
|
||||
|
// ts!: number;
|
||||
// mode!: string;
|
// mode!: string;
|
||||
// adata!: string;
|
// adata!: string;
|
||||
// cipher!: string;
|
// cipher!: string;
|
||||
// salt!: string;
|
// salt!: string;
|
||||
// cipherText!: string;
|
|
||||
|
|
||||
iv!: string; |
|
||||
v!: number; |
|
||||
iter!: number; |
|
||||
ks!: number; |
|
||||
ts!: number; |
|
||||
mode!: string; |
|
||||
adata!: string; |
|
||||
cipher!: string; |
|
||||
salt!: string; |
|
||||
ct!: string; |
|
||||
|
// ct!: string;
|
||||
|
|
||||
// public toMessageCipherDTO {
|
|
||||
|
// // public toMessageCipherDTO {
|
||||
|
|
||||
|
// // }
|
||||
// }
|
// }
|
||||
|
|
||||
|
export interface MessageCipherDTO { |
||||
|
iv: string, |
||||
|
v: number, |
||||
|
iter: number, |
||||
|
ks: number, |
||||
|
ts: number, |
||||
|
mode: string, |
||||
|
adata: string, |
||||
|
cipher: string, |
||||
|
salt: string, |
||||
|
ct: string, |
||||
} |
} |
@ -1,11 +1,10 @@ |
|||||
import { EncryptionService } from "./EncryptionService"; |
import { EncryptionService } from "./EncryptionService"; |
||||
import { SJCLEncryptionService } from "./SJCLEncryptionService"; |
import { SJCLEncryptionService } from "./SJCLEncryptionService"; |
||||
import PromiseWorker = require('promise-worker'); |
|
||||
// import PromiseWorker from "promise-worker";
|
|
||||
|
// import PromiseWorker = require('promise-worker');
|
||||
|
import PromiseWorker from "promise-worker"; |
||||
|
|
||||
export class EncryptionServiceFactory { |
export class EncryptionServiceFactory { |
||||
private static readonly _worker = new Worker('/js/worker.js'); |
private static readonly _worker = new Worker('/js/worker.js'); |
||||
// @ts-ignore
|
|
||||
private static readonly _promiseWorker = new PromiseWorker(EncryptionServiceFactory._worker); |
private static readonly _promiseWorker = new PromiseWorker(EncryptionServiceFactory._worker); |
||||
public static getEncryptionService(): EncryptionService { |
public static getEncryptionService(): EncryptionService { |
||||
return new SJCLEncryptionService(this._promiseWorker) |
return new SJCLEncryptionService(this._promiseWorker) |
||||
|
@ -1,8 +1,9 @@ |
|||||
import registerPromiseWorker from 'promise-worker/register'; |
import registerPromiseWorker from 'promise-worker/register'; |
||||
import * as sjcl from 'sjcl' |
import * as sjcl from 'sjcl' |
||||
|
import { MessageCipherDTO } from '../../chat/dto/MessageCipherDTO'; |
||||
|
|
||||
|
|
||||
registerPromiseWorker((payload: { passphrase: string, cipher: string }) => { |
|
||||
|
registerPromiseWorker((payload: { passphrase: string, cipher: MessageCipherDTO }) => { |
||||
// console.log(payload)
|
// console.log(payload)
|
||||
// console.log('decrypted = ' + sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)));
|
// console.log('decrypted = ' + sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)));
|
||||
return sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)) |
return sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue