Заработало AES-256-CBC шифрование!
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
"@angular/router": "^4.0.0",
|
"@angular/router": "^4.0.0",
|
||||||
"@types/crypto-js": "^3.1.33",
|
"@types/crypto-js": "^3.1.33",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"cryptojs": "^2.5.3",
|
"crypto-js": "^3.1.9-1",
|
||||||
"rxjs": "^5.1.0",
|
"rxjs": "^5.1.0",
|
||||||
"zone.js": "^0.8.4"
|
"zone.js": "^0.8.4"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Http, Headers } from '@angular/http';
|
import { Http, Headers } from '@angular/http';
|
||||||
import { AES, SHA256 } from 'cryptojs';
|
import * as CryptoJS from 'crypto-js';
|
||||||
|
|
||||||
export class NewMessage {
|
export class NewMessage {
|
||||||
public Content: string;
|
public Content: string;
|
||||||
@@ -32,15 +32,14 @@ export class AppComponent {
|
|||||||
this.showDialog = false;
|
this.showDialog = false;
|
||||||
this.textarea = null;
|
this.textarea = null;
|
||||||
}
|
}
|
||||||
GenerateKeyPair(): void {
|
|
||||||
}
|
|
||||||
AcceptNew(): void {
|
AcceptNew(): void {
|
||||||
console.log(this.textarea);
|
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;
|
const obj = new NewMessage;
|
||||||
obj.Content = encrypted_text;
|
obj.Content = encrypted_text.toString();
|
||||||
const body = JSON.stringify(obj);
|
const body = JSON.stringify(obj);
|
||||||
console.log(body);
|
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' });
|
// const headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
|
||||||
// this.http.post((this.address + 'new'), body, { headers: headers });
|
// this.http.post((this.address + 'new'), body, { headers: headers });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|||||||
import { MdButtonModule, MdCheckboxModule, MdToolbarModule, MdSidenavModule, MdCardModule} from '@angular/material';
|
import { MdButtonModule, MdCheckboxModule, MdToolbarModule, MdSidenavModule, MdCardModule} from '@angular/material';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { MdInputModule } from "@angular/material";
|
import { MdInputModule } from '@angular/material';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|||||||
Reference in New Issue
Block a user