Skip to content
This repository was archived by the owner on Feb 10, 2022. It is now read-only.

Commit 8f2d33c

Browse files
committed
More commenting
1 parent 58df84d commit 8f2d33c

File tree

6 files changed

+30
-146
lines changed

6 files changed

+30
-146
lines changed

hp-app/js/angular-module.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ app.controller("myCtrl", function(
270270
"selectPatientKeysByPatientID?p=resource%3Anz.ac.auckland.Patient%23" +
271271
patient.id;
272272

273-
273+
// fetch encrypted patient key from blockchain
274274
$http.get(endpoint).then(function(response) {
275275
console.log(response.data);
276276
if (response.data.length === 0) {
@@ -283,6 +283,7 @@ app.controller("myCtrl", function(
283283

284284
patientKey = $scope.tryDecrypt(encryptedKey);
285285

286+
// open modal
286287
ModalService.showModal({
287288
templateUrl: "./recordsModal.html",
288289
controller: "recordsController",

hp-app/js/encryption.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ const_publicKey = '';
44
const_privateKey = '';
55

66
function loaded() {
7-
//var buf = crypto.randomBytes(1024 / 8) // 128 bytes
8-
//buf = new Uint32Array(new Uint8Array(buf).buffer)
9-
10-
//sjcl.random.addEntropy(buf, 1024, "crypto.randomBytes")
117

128
sjcl.random.startCollectors();
139
}
@@ -50,21 +46,6 @@ function kdf(password, salt){
5046

5147
function symEncrypt(data, key){
5248

53-
/* console.log("Encrypting data: Data = " + data + " Key = " + key);
54-
55-
if (data === '') { return ''; }
56-
if (key.length == 0) {
57-
error("Need a key!");
58-
return;
59-
}
60-
61-
key = sjcl.codec.hex.toBits(key);
62-
63-
// Key must be in bit array
64-
var result = sjcl.encrypt(key, data, {iv : iv, mode : "ccm"});
65-
66-
console.log(result);*/
67-
6849
var encrypted = CryptoJS.AES.encrypt(data, key);
6950

7051
console.log(encrypted);
@@ -75,27 +56,6 @@ function symEncrypt(data, key){
7556

7657
function symDecrypt(encryptedData, key){
7758

78-
/* if (encryptedData.length === 0) { return ''; }
79-
if (key.length == 0) {
80-
error("Need a key!");
81-
return;
82-
}
83-
if (iv.length === 0) {
84-
error("Can't decrypt: need an IV!"); return;
85-
}
86-
87-
key = sjcl.codec.hex.toBits(key);
88-
89-
key = new sjcl.cipher.aes(key);
90-
91-
initialisationVector = sjcl.codec.base64.toBits(iv);
92-
93-
encryptedData = sjcl.codec.base64.toBits(encryptedData);
94-
95-
var data = sjcl.codec.utf8String.fromBits(sjcl.mode.ccm.decrypt(key, encryptedData, initialisationVector));
96-
97-
console.log(data); */
98-
9959
console.log(encryptedData);
10060

10161
var decrypted = CryptoJS.AES.decrypt(encryptedData, key);

patient-app/js/angular-module.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,6 @@ app.controller("myCtrl", function (
275275
_records = $scope.myArray[index].records;
276276
};
277277

278-
$scope.editPatient = function () {
279-
var patientDetails = $scope.myArray;
280-
ModalService.showModal({
281-
templateUrl: "./patientModal.html",
282-
controller: "PatientController",
283-
preClose: modal => {
284-
modal.element.modal("hide");
285-
},
286-
inputs: {
287-
title: "A More Complex Example",
288-
patient: patientDetails,
289-
update: true
290-
}
291-
}).then(function (modal) {
292-
modal.element.modal();
293-
modal.close.then(function (result) {
294-
$(".modal-backdrop").remove();
295-
});
296-
});
297-
};
298-
299278
$scope.getAllRecords = function () {
300279
if (!isCredsProvided()) {
301280
return;
@@ -370,6 +349,30 @@ app.controller("myCtrl", function (
370349

371350
// ------ END CRUD & TRANSACTIONS -----
372351

352+
// ------ MODALS -----
353+
$scope.editPatient = function () {
354+
var patientDetails = $scope.myArray;
355+
ModalService.showModal({
356+
templateUrl: "./patientModal.html",
357+
controller: "PatientController",
358+
preClose: modal => {
359+
modal.element.modal("hide");
360+
},
361+
inputs: {
362+
title: "A More Complex Example",
363+
patient: patientDetails,
364+
update: true
365+
}
366+
}).then(function (modal) {
367+
modal.element.modal();
368+
modal.close.then(function (result) {
369+
$(".modal-backdrop").remove();
370+
});
371+
});
372+
};
373+
374+
// ------ END MODALS -----
375+
373376
// ----- RESPONSE HANDLING -----
374377
/**
375378
* Show response message in a pop-up dialog box

patient-app/js/encryption.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ const_publicKey = '';
44
const_privateKey = '';
55

66
function loaded() {
7-
//var buf = crypto.randomBytes(1024 / 8) // 128 bytes
8-
//buf = new Uint32Array(new Uint8Array(buf).buffer)
9-
10-
//sjcl.random.addEntropy(buf, 1024, "crypto.randomBytes")
117

128
sjcl.random.startCollectors();
139
}
@@ -50,21 +46,6 @@ function kdf(password, salt){
5046

5147
function symEncrypt(data, key){
5248

53-
/* console.log("Encrypting data: Data = " + data + " Key = " + key);
54-
55-
if (data === '') { return ''; }
56-
if (key.length == 0) {
57-
error("Need a key!");
58-
return;
59-
}
60-
61-
key = sjcl.codec.hex.toBits(key);
62-
63-
// Key must be in bit array
64-
var result = sjcl.encrypt(key, data, {iv : iv, mode : "ccm"});
65-
66-
console.log(result);*/
67-
6849
var encrypted = CryptoJS.AES.encrypt(data, key);
6950

7051
console.log(encrypted);
@@ -75,27 +56,6 @@ function symEncrypt(data, key){
7556

7657
function symDecrypt(encryptedData, key){
7758

78-
/* if (encryptedData.length === 0) { return ''; }
79-
if (key.length == 0) {
80-
error("Need a key!");
81-
return;
82-
}
83-
if (iv.length === 0) {
84-
error("Can't decrypt: need an IV!"); return;
85-
}
86-
87-
key = sjcl.codec.hex.toBits(key);
88-
89-
key = new sjcl.cipher.aes(key);
90-
91-
initialisationVector = sjcl.codec.base64.toBits(iv);
92-
93-
encryptedData = sjcl.codec.base64.toBits(encryptedData);
94-
95-
var data = sjcl.codec.utf8String.fromBits(sjcl.mode.ccm.decrypt(key, encryptedData, initialisationVector));
96-
97-
console.log(data); */
98-
9959
console.log(encryptedData);
10060

10161
var decrypted = CryptoJS.AES.decrypt(encryptedData, key);

web-app/js/angular-module.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ app.controller('myCtrl', function ($scope, $http, $websocket, ModalService) {
3131
$scope.wKey
3232

3333
//----- End Fields ------
34-
34+
3535
// view JSON data on screen
3636
$scope.viewData = function (data) {
3737

@@ -73,7 +73,7 @@ app.controller('myCtrl', function ($scope, $http, $websocket, ModalService) {
7373
}, _error)
7474
}
7575

76-
// handles deletion either patients or HPs
76+
// handles deletion for either patients or HPs
7777
$scope.delete = function (index) {
7878
var isConfirmed = confirm("Are you sure you want to delete this entity?")
7979

@@ -309,7 +309,7 @@ app.controller('myCtrl', function ($scope, $http, $websocket, ModalService) {
309309
// ------ END ENCRYPTION HANDLING ------
310310

311311

312-
// ----- Web socker and event handling logic -----
312+
// ----- Web socket and event handling logic -----
313313
var ws = $websocket.$new(webport);
314314

315315
ws.$on('$open', function () { // it listents for 'incoming event'
@@ -370,7 +370,7 @@ app.controller('myCtrl', function ($scope, $http, $websocket, ModalService) {
370370

371371
});
372372

373-
$scope.getPatients()
373+
$scope.getPatients()
374374

375375

376376
})

web-app/js/encryption.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ const_publicKey = '';
44
const_privateKey = '';
55

66
function loaded() {
7-
//var buf = crypto.randomBytes(1024 / 8) // 128 bytes
8-
//buf = new Uint32Array(new Uint8Array(buf).buffer)
9-
10-
//sjcl.random.addEntropy(buf, 1024, "crypto.randomBytes")
117

128
sjcl.random.startCollectors();
139
}
@@ -50,21 +46,6 @@ function kdf(password, salt){
5046

5147
function symEncrypt(data, key){
5248

53-
/* console.log("Encrypting data: Data = " + data + " Key = " + key);
54-
55-
if (data === '') { return ''; }
56-
if (key.length == 0) {
57-
error("Need a key!");
58-
return;
59-
}
60-
61-
key = sjcl.codec.hex.toBits(key);
62-
63-
// Key must be in bit array
64-
var result = sjcl.encrypt(key, data, {iv : iv, mode : "ccm"});
65-
66-
console.log(result);*/
67-
6849
var encrypted = CryptoJS.AES.encrypt(data, key);
6950

7051
console.log(encrypted);
@@ -75,27 +56,6 @@ function symEncrypt(data, key){
7556

7657
function symDecrypt(encryptedData, key){
7758

78-
/* if (encryptedData.length === 0) { return ''; }
79-
if (key.length == 0) {
80-
error("Need a key!");
81-
return;
82-
}
83-
if (iv.length === 0) {
84-
error("Can't decrypt: need an IV!"); return;
85-
}
86-
87-
key = sjcl.codec.hex.toBits(key);
88-
89-
key = new sjcl.cipher.aes(key);
90-
91-
initialisationVector = sjcl.codec.base64.toBits(iv);
92-
93-
encryptedData = sjcl.codec.base64.toBits(encryptedData);
94-
95-
var data = sjcl.codec.utf8String.fromBits(sjcl.mode.ccm.decrypt(key, encryptedData, initialisationVector));
96-
97-
console.log(data); */
98-
9959
console.log(encryptedData);
10060

10161
var decrypted = CryptoJS.AES.decrypt(encryptedData, key);

0 commit comments

Comments
 (0)