From 8dc4b0422b08418bf1dbafcb360bc1f5f0dc7a2f Mon Sep 17 00:00:00 2001 From: Vlad Utkin Date: Mon, 22 May 2017 14:45:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B0=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BB=20=D0=BD=D0=B0=20cryptojs=20=D0=B8=20typings?= =?UTF-8?q?.=20=D0=9F=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D1=8B=20=D1=81?= =?UTF-8?q?=20Webpack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 ++ src/app/app.component.html | 1 - src/app/app.component.ts | 11 ++--------- src/tsconfig.app.json | 8 +++++++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 189611c..8a73f86 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", + "@types/crypto-js": "^3.1.33", "core-js": "^2.4.1", + "cryptojs": "^2.5.3", "rxjs": "^5.1.0", "zone.js": "^0.8.4" }, diff --git a/src/app/app.component.html b/src/app/app.component.html index 94bd2e4..3aa9414 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -2,7 +2,6 @@ Log Manager - diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ca4a662..c967a5e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { Http, Headers } from '@angular/http'; +import { AES, SHA256 } from 'cryptojs'; export class NewMessage { public Content: string; @@ -35,15 +36,7 @@ export class AppComponent { } AcceptNew(): void { console.log(this.textarea); - crypto.subtle.generateKey( - { - name: 'AES-GCM', - length: 256, // can be 128, 192, or 256 - }, - true, // whether the key is extractable (i.e. can be used in exportKey) - ['encrypt', 'decrypt'] // can "encrypt", "decrypt", "wrapKey", or "unwrapKey" - ).then(function(key) { }); - const encrypted_text = this.textarea; + const encrypted_text = AES(this.textarea, this.pass); const obj = new NewMessage; obj.Content = encrypted_text; const body = JSON.stringify(obj); diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 5e2507d..b229ec4 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -4,10 +4,16 @@ "outDir": "../out-tsc/app", "module": "es2015", "baseUrl": "", - "types": [] + "types": [ + "node" + ] }, "exclude": [ "test.ts", "**/*.spec.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" ] }