Именена библиотека на webcrypto. Ошибки при подписи сообщенияю
This commit is contained in:
@@ -22,9 +22,9 @@
|
|||||||
"@angular/platform-browser": "^4.0.0",
|
"@angular/platform-browser": "^4.0.0",
|
||||||
"@angular/platform-browser-dynamic": "^4.0.0",
|
"@angular/platform-browser-dynamic": "^4.0.0",
|
||||||
"@angular/router": "^4.0.0",
|
"@angular/router": "^4.0.0",
|
||||||
"standard-ecies": "1.0.0",
|
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"rxjs": "^5.1.0",
|
"rxjs": "^5.1.0",
|
||||||
|
"webcrypto": "^0.1.0",
|
||||||
"zone.js": "^0.8.4"
|
"zone.js": "^0.8.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<span>Log Manager</span>
|
<span>Log Manager</span>
|
||||||
<span style="flex: 1 1 auto;"></span>
|
<span style="flex: 1 1 auto;"></span>
|
||||||
<span>
|
<span>
|
||||||
<button md-button (click)="GenerateKeyPair();">Para</button>
|
|
||||||
<button md-raised-button color="primary" (click)="AddNew();">Новый</button>
|
<button md-raised-button color="primary" (click)="AddNew();">Новый</button>
|
||||||
<button (click)="Exit();" md-raised-button color="warn">Выхода нет</button>
|
<button (click)="Exit();" md-raised-button color="warn">Выхода нет</button>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Http, Headers, Response } from '@angular/http';
|
import { Http, Headers } from '@angular/http';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'webcrypto';
|
||||||
import * as ecies from 'standard-ecies';
|
|
||||||
|
|
||||||
export class NewMessage {
|
export class NewMessage {
|
||||||
public Content: string;
|
public Content: string;
|
||||||
public Sign: string;
|
public Hash: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -14,19 +13,20 @@ export class NewMessage {
|
|||||||
styleUrls: ['./app.component.css']
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
cryptopt = {
|
pubkey = '-----BEGIN PUBLIC KEY-----\n' +
|
||||||
hashName: 'sha256',
|
'AAAAB3NzaC1yc2EAAAABJQAAAgEAoGk22+PjQH4TEwT0v8qnYxm0YKcil4GB2j03\n' +
|
||||||
hashLength: '32',
|
'Ck5RamWid+TZGFH4aW0ekYe1aBB3Qt7FCs49zR3jxPpeQsv4AjehCB6AVU3R1rfL\n' +
|
||||||
macName: 'sha256',
|
'2ze+qiERUVFLcrYr1pzbABn/5YWwkPQFZlgPx82bOMCavDWCY9Z7xLmxeqcdP6P0\n' +
|
||||||
macLength: '32',
|
'7pbOe3UnIOSxPZblXvSHiYueAzL1o2bqaT2aJtF2yxuPQq/XDkBjAQ/kcOpVYr5Y\n' +
|
||||||
curveName: 'secp256k1',
|
'm9/5WwI8bBiipY+xLlXSa78TvVdoTZHdf7EIXZD0rGxmhxOT7KjO1QXycpprX7Yz\n' +
|
||||||
symmetricChyperName: 'aes-256-cbc',
|
'eOQVgc8W+B9fCkAaVaznNNo+wfVUUc5qp5urAz/OcF9X0AfjKjI9pXh6eqeipNA1\n' +
|
||||||
iv: 6,
|
'hBYeGrsxSOuTcd48t2OCQzt9213oj7PZEUImAnkXP3sYKykn2w2HseEzG9q/WszV\n' +
|
||||||
keyFormat: 'uncompressed',
|
'3mENtPkApY7EapMfNV8wN0H7q8zZSv4AwkG3jhWKYgRfHURNMkx9jdnF2H+LbuH+\n' +
|
||||||
s1: null,
|
'uyAh+SXDNuu8iEmMNrZBaUAVPJlqxX1O7i0t0XYiC509jdQvFIGI2FGVPXtudk5c\n' +
|
||||||
s2: null
|
'IXX0miZ8ZXUJHBKu/j/piWzejJTGHfdgBcA9gdnskZjgoNyBkU2adURMgkKwXA+n\n' +
|
||||||
};
|
'Nb6WC+oxojn8RJGz127gwGGVgChX7h+uF2SL8m4C1AgBkV63CU9BNtRiAzZcCJhL\n' +
|
||||||
ecdh = crypto.createECDH(this.cryptopt.curveName);
|
'V+g5roU=\n' +
|
||||||
|
'-----END PUBLIC KEY-----';
|
||||||
showCon = false;
|
showCon = false;
|
||||||
showDialog = false;
|
showDialog = false;
|
||||||
address = 'http://127.0.0.1:8000/api/';
|
address = 'http://127.0.0.1:8000/api/';
|
||||||
@@ -50,17 +50,19 @@ export class AppComponent {
|
|||||||
this.textarea = null;
|
this.textarea = null;
|
||||||
}
|
}
|
||||||
GenerateKeyPair(): void {
|
GenerateKeyPair(): void {
|
||||||
this.ecdh.generateKeys();
|
|
||||||
console.log(this.ecdh.getPrivateKey());
|
|
||||||
console.log(this.ecdh.getPublicKey());
|
|
||||||
}
|
}
|
||||||
AcceptNew(): void {
|
AcceptNew(): void {
|
||||||
console.log(this.textarea);
|
console.log(this.textarea);
|
||||||
|
console.log(this.pubkey);
|
||||||
|
const encrypted_text = crypto.publicEncrypt(this.pubkey, this.textarea);
|
||||||
const obj = new NewMessage;
|
const obj = new NewMessage;
|
||||||
obj.Content = this.textarea;
|
obj.Content = encrypted_text;
|
||||||
obj.Sign = '';
|
obj.Hash = '';
|
||||||
const body = JSON.stringify(obj);
|
const body = JSON.stringify(obj);
|
||||||
const headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
|
console.log(body);
|
||||||
this.http.post((this.address + 'new'), body, { headers: headers });
|
const dejson = JSON.parse(body);
|
||||||
|
console.log(dejson);
|
||||||
|
// const headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
|
||||||
|
// this.http.post((this.address + 'new'), body, { headers: headers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user