Change encryption libruary to standart-ecies. Problems with import node crypto module.
This commit is contained in:
@@ -22,8 +22,7 @@
|
|||||||
"@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",
|
||||||
"bitcore-ecies": "^1.0.3",
|
"standard-ecies": "1.0.0",
|
||||||
"bitcore-lib": "^0.14.0",
|
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"rxjs": "^5.1.0",
|
"rxjs": "^5.1.0",
|
||||||
"zone.js": "^0.8.4"
|
"zone.js": "^0.8.4"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<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,6 +1,7 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Http, Headers, Response } from '@angular/http';
|
import { Http, Headers, Response } from '@angular/http';
|
||||||
import { PrivateKey, PublicKey } from 'bitcore-lib';
|
import * as crypto from 'crypto';
|
||||||
|
import * as ecies from 'standard-ecies';
|
||||||
|
|
||||||
export class NewMessage {
|
export class NewMessage {
|
||||||
public Content: string;
|
public Content: string;
|
||||||
@@ -13,6 +14,19 @@ export class NewMessage {
|
|||||||
styleUrls: ['./app.component.css']
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
|
cryptopt = {
|
||||||
|
hashName: 'sha256',
|
||||||
|
hashLength: '32',
|
||||||
|
macName: 'sha256',
|
||||||
|
macLength: '32',
|
||||||
|
curveName: 'secp256k1',
|
||||||
|
symmetricChyperName: 'aes-256-cbc',
|
||||||
|
iv: 6,
|
||||||
|
keyFormat: 'uncompressed',
|
||||||
|
s1: null,
|
||||||
|
s2: null
|
||||||
|
};
|
||||||
|
ecdh = crypto.createECDH(this.cryptopt.curveName);
|
||||||
showCon = false;
|
showCon = false;
|
||||||
showDialog = false;
|
showDialog = false;
|
||||||
address = 'http://127.0.0.1:8000/api/';
|
address = 'http://127.0.0.1:8000/api/';
|
||||||
@@ -36,10 +50,9 @@ export class AppComponent {
|
|||||||
this.textarea = null;
|
this.textarea = null;
|
||||||
}
|
}
|
||||||
GenerateKeyPair(): void {
|
GenerateKeyPair(): void {
|
||||||
const keypair = new PrivateKey();
|
this.ecdh.generateKeys();
|
||||||
const pubpair = new PublicKey(keypair, true);
|
console.log(this.ecdh.getPrivateKey());
|
||||||
console.log(keypair.toString());
|
console.log(this.ecdh.getPublicKey());
|
||||||
console.log(pubpair.toString());
|
|
||||||
}
|
}
|
||||||
AcceptNew(): void {
|
AcceptNew(): void {
|
||||||
console.log(this.textarea);
|
console.log(this.textarea);
|
||||||
|
|||||||
Reference in New Issue
Block a user