Commit c4e90f7a authored by Harrison Stahl's avatar Harrison Stahl

started to refactor code

parent f19a1e6e
......@@ -6881,61 +6881,80 @@ process.umask = function() { return 0; };
var keypair = require('keypair');
var rs = require('jsrsasign');
function generateKeypair() {
var pair = keypair();
if(typeof(Storage) !== "undefined") {
localStorage.setItem("pk", pair.private);
}
else {
console.log("Local storage not supported.");
}
function lsSupport(){
if(typeof(Storage) !== "undefined") {
return true
}
else{
return false
}
}
function genKeypair() {
var pair = keypair();
return pair
}
function hasKey(){
if(lsSupport()) {
if(localStorage.getItem("pair") !== null){
return true
}
return false;
}
}
function getKeypair() {
if(typeof(Storage) !== "undefined") {
var priv = localStorage.getItem("pk");
if(priv == null) {
throw "Null pk";
}
return priv;
}
else {
console.log("Local storage not supported.");
}
var pair = localStorage.getItem("pair");
if(pair == null) {
return false
}
return pair;
}
}
function signData(privKey, data) {
var sig = new rs.KJUR.crypto.Signature({"alg":"SHA256withRSA"});
sig.init(privKey);
sig.updateString(data);
sigHex = sig.sign();
return sigHex;
var sig = new rs.KJUR.crypto.Signature({"alg":"SHA256withRSA"});
sig.init(privKey);
sig.updateString(data);
sigHex = sig.sign();
return sigHex;
}
function verifySig(pubKey, sigHex, data) {
var sig = new rs.KJUR.crypto.Signature({"alg":"SHA256withRSA"});
sig.init(pubKey);
sig.updateString(data);
var isValid = sig.verify(sigHex);
return isValid;
var sig = new rs.KJUR.crypto.Signature({"alg":"SHA256withRSA"});
sig.init(pubKey);
sig.updateString(data);
var isValid = sig.verify(sigHex);
return isValid;
}
function load() {
$('body').load('main');
try {
var privKey = getKeypair();
console.log("Private Key from LocalStorage: " + privKey);
$('#pkDiv').html(privKey);
}
catch(err) {
$('#modal').modal('show');
}
}
function getID(){}
function keyPrompt(){}
function youSuckPrompt(){}
//How's it going?
//Enjoy the party!
//Also don't fuck with this, it's a party jackass
load();
if(lsSupport()){
if(hasKey()){
}
else{
keyPrompt();
}
pair = getKeypair()
console.log(pair)
}
else{
youSuckPrompt();
}
},{"jsrsasign":4,"keypair":5}]},{},[7]);
},{"keypair":1}]},{},[3]);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment