From fdcfeca8800d34dc8a18684b839a20225e60529c Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 17 May 2017 17:13:37 +0300 Subject: [PATCH] Change encryption libruary to standart-ecies. Problems with import node crypto module. --- package.json | 3 +-- src/app/app.component.html | 1 + src/app/app.component.ts | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0368c18..cba4ada 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,7 @@ "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", - "bitcore-ecies": "^1.0.3", - "bitcore-lib": "^0.14.0", + "standard-ecies": "1.0.0", "core-js": "^2.4.1", "rxjs": "^5.1.0", "zone.js": "^0.8.4" diff --git a/src/app/app.component.html b/src/app/app.component.html index 3aa9414..1ec2ad8 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -2,6 +2,7 @@ Log Manager + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index bbf0730..ad53683 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; 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 { public Content: string; @@ -13,6 +14,19 @@ export class NewMessage { styleUrls: ['./app.component.css'] }) 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; showDialog = false; address = 'http://127.0.0.1:8000/api/'; @@ -36,10 +50,9 @@ export class AppComponent { this.textarea = null; } GenerateKeyPair(): void { - const keypair = new PrivateKey(); - const pubpair = new PublicKey(keypair, true); - console.log(keypair.toString()); - console.log(pubpair.toString()); + this.ecdh.generateKeys(); + console.log(this.ecdh.getPrivateKey()); + console.log(this.ecdh.getPublicKey()); } AcceptNew(): void { console.log(this.textarea);