Add bitcore encryption. Unfortunately not working(

This commit is contained in:
2017-05-16 23:57:30 +03:00
parent 0f721b85d6
commit b23d6179c6
3 changed files with 52 additions and 2 deletions

View File

@@ -22,6 +22,8 @@
"@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",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"

View File

@@ -1,12 +1,24 @@
<md-toolbar color="primary">
<span>Log Manager</span>
<span style="flex: 1 1 auto;"></span>
<span><button (click)="Exit();" md-raised-button color="warn">Выхода нет</button></span>
<span>
<button md-raised-button color="primary" (click)="AddNew();">Новый</button>
<button (click)="Exit();" md-raised-button color="warn">Выхода нет</button>
</span>
</md-toolbar>
<md-card *ngIf="showCon && showDialog">
<md-input-container style="width: 100%" floatPlaceholder="auto|always|never">
<textarea mdInput mdTextareaAutosize name="textarea" [(ngModel)]="textarea" required
placeholder="Текст заметки"></textarea>
</md-input-container>
<button (click)="AcceptNew();" md-raised-button color="primary">Добавить</button>
<button (click)="HideNew();" md-raised-button color="warn">Убрать</button>
</md-card>
<md-card *ngIf="!showCon">
<md-input-container>
<input (change)="pass=$event.target.value" mdInput placeholder="Пароль" type="password" id="password">
<input name="pass" [(ngModel)]="pass" mdInput placeholder="Пароль" type="password" id="password">
</md-input-container>
<button (click)="Decrypt();" md-raised-button>Расшифровать заголовки</button>
</md-card>

View File

@@ -1,4 +1,11 @@
import { Component } from '@angular/core';
import { Http, Headers, Response } from '@angular/http';
import { PrivateKey, PublicKey } from 'bitcore-lib';
export class NewMessage {
public Content: string;
public Sign: string;
}
@Component({
selector: 'app-root',
@@ -7,11 +14,40 @@ import { Component } from '@angular/core';
})
export class AppComponent {
showCon = false;
showDialog = false;
address = 'http://127.0.0.1:8000/api/';
pass: string;
textarea: string;
constructor(private http: Http) {}
Exit(): void {
this.showCon = false;
}
Decrypt(): void {
this.showCon = true;
if (this.pass === 'genmekey') {
this.GenerateKeyPair();
}
}
AddNew(): void {
this.showDialog = true;
}
HideNew(): void {
this.showDialog = false;
this.textarea = null;
}
GenerateKeyPair(): void {
const keypair = new PrivateKey();
const pubpair = new PublicKey(keypair, true);
console.log(keypair.toString());
console.log(pubpair.toString());
}
AcceptNew(): void {
console.log(this.textarea);
const obj = new NewMessage;
obj.Content = this.textarea;
obj.Sign = '';
const body = JSON.stringify(obj);
const headers = new Headers({ 'Content-Type': 'application/json;charset=utf-8' });
this.http.post((this.address + 'new'), body, { headers: headers });
}
}