Заработало AES-256-CBC шифрование!

This commit is contained in:
2017-05-24 23:49:30 +03:00
parent 8dc4b0422b
commit 4623d56cca
3 changed files with 6 additions and 7 deletions

View File

@@ -24,7 +24,7 @@
"@angular/router": "^4.0.0",
"@types/crypto-js": "^3.1.33",
"core-js": "^2.4.1",
"cryptojs": "^2.5.3",
"crypto-js": "^3.1.9-1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { Http, Headers } from '@angular/http';
import { AES, SHA256 } from 'cryptojs';
import * as CryptoJS from 'crypto-js';
export class NewMessage {
public Content: string;
@@ -32,15 +32,14 @@ export class AppComponent {
this.showDialog = false;
this.textarea = null;
}
GenerateKeyPair(): void {
}
AcceptNew(): void {
console.log(this.textarea);
const encrypted_text = AES(this.textarea, this.pass);
const encrypted_text = CryptoJS.AES.encrypt(this.textarea, this.pass);
const obj = new NewMessage;
obj.Content = encrypted_text;
obj.Content = encrypted_text.toString();
const body = JSON.stringify(obj);
console.log(body);
console.log(CryptoJS.AES.decrypt(obj.Content, this.pass).toString(CryptoJS.enc.Utf8));
// const headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
// this.http.post((this.address + 'new'), body, { headers: headers });
}

View File

@@ -6,7 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MdButtonModule, MdCheckboxModule, MdToolbarModule, MdSidenavModule, MdCardModule} from '@angular/material';
import { AppComponent } from './app.component';
import { MdInputModule } from "@angular/material";
import { MdInputModule } from '@angular/material';
@NgModule({
declarations: [