-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3762b7a
commit bbbe9cf
Showing
17 changed files
with
3,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<html> | ||
<head> | ||
<title>NextGen</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<script language="JavaScript" type="text/javascript" src="src/libs/zepto.min.js"></script> | ||
<script language="JavaScript" type="text/javascript" src="src/libs/pako.min.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/libs/jquery.identicon5.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/libs/sjcl.js"></script> | ||
<script language="JavaScript" type="text/javascript" src="src/libs/sjcl.ccm_hack.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/libs/elliptic.min.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/libs/utf8array.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/libs/base58.js"></script> | ||
|
||
<script language="JavaScript" type="text/javascript" src="src/helpers.js"></script> | ||
<script language="JavaScript" type="text/javascript" src="src/main.js"></script> | ||
</head> | ||
<body> | ||
|
||
|
||
<table style="width: 100%; text-align: center;" border=1> | ||
<tr><td rowspan=2><form id="encode"> | ||
<p style="text-align: center;"><textarea id="in_message" rows=30 cols=60></textarea><br/> | ||
<input type="submit" value="Encode"/> | ||
<br><label>Hide Sender: <input name="hide_sender" type="checkbox" /></label> | ||
<br><label>Hide Contacts: <input name="hide_contacts" type="checkbox" /></label> | ||
</p> | ||
</form> | ||
</td> | ||
|
||
|
||
<td rowspan=2><form id="decode"> | ||
<p style="text-align: center;"><textarea id="in_coded" rows=40 cols=65 style="font-size: x-small;"></textarea><br/> | ||
<input type="submit" value="Decode"/></p> | ||
<p id="contacts_output" style="font-size: x-small;"></p> | ||
</form> | ||
|
||
</td> | ||
|
||
|
||
|
||
|
||
<td><form id="login"> | ||
<p><label>Password: <input name="login_pwd" type="text" style="color: #ddd;"/></label><br/> | ||
<label>Salt: <input name="login_salt" type="text" style="color: #ddd;"/></label></p> | ||
<p><input type="submit" value="Log in!"/></p> | ||
<p id="login_info" style="font-size: x-small;"></p> | ||
</form> | ||
</td> | ||
</tr> | ||
|
||
|
||
|
||
<tr><td style="width: 600px;"><form id="contacts"> | ||
<p><label>Addres: <input name="contact_address" type="text" length=90 /></label><input type="submit" value="Add"/></p> | ||
<textarea id="contacts_list" rows=6 cols=90 style="font-size: x-small;"></textarea> | ||
<p><input type="button" value="Clear" id="clear_contacts"/></p> | ||
</form></td></tr> | ||
</table> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "desudesutalk", | ||
"version": "0.0.1", | ||
"devDependencies": { | ||
"grunt": "*", | ||
"grunt-contrib-concat": "*", | ||
"grunt-contrib-watch": "*", | ||
"grunt-contrib-jshint": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
var arrayBufferDataUri = function (raw) { | ||
"use strict"; | ||
|
||
var base64 = '', | ||
encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', | ||
bytes = new Uint8Array(raw), | ||
byteLength = bytes.byteLength, | ||
byteRemainder = byteLength % 3, | ||
mainLength = byteLength - byteRemainder, | ||
a, b, c, d, | ||
chunk; | ||
|
||
// Main loop deals with bytes in chunks of 3 | ||
for (var i = 0; i < mainLength; i = i + 3) { | ||
// Combine the three bytes into a single integer | ||
chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]; | ||
|
||
// Use bitmasks to extract 6-bit segments from the triplet | ||
a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18 | ||
b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12 | ||
c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6 | ||
d = chunk & 63; // 63 = 2^6 - 1 | ||
// Convert the raw binary segments to the appropriate ASCII encoding | ||
base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d]; | ||
} | ||
|
||
// Deal with the remaining bytes and padding | ||
if (byteRemainder == 1) { | ||
chunk = bytes[mainLength]; | ||
|
||
a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2 | ||
// Set the 4 least significant bits to zero | ||
b = (chunk & 3) << 4; // 3 = 2^2 - 1 | ||
base64 += encodings[a] + encodings[b] + '=='; | ||
} else if (byteRemainder == 2) { | ||
chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1]; | ||
|
||
a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10 | ||
b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4 | ||
// Set the 2 least significant bits to zero | ||
c = (chunk & 15) << 2; // 15 = 2^4 - 1 | ||
base64 += encodings[a] + encodings[b] + encodings[c] + '='; | ||
} | ||
|
||
return base64; | ||
}; | ||
|
||
var decodeBase64 = function (s) { | ||
var e={},i,b=0,c,x,l=0,a,r=[],w=String.fromCharCode,L=s.length; | ||
var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
for(i=0;i<64;i++){e[A.charAt(i)]=i;} | ||
for(x=0;x<L;x++){ | ||
c=e[s.charAt(x)];b=(b<<6)+c;l+=6; | ||
while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r.push(a));} | ||
} | ||
return r; | ||
}; | ||
|
||
// Convert a hex string to a byte array | ||
var hexToBytes = function (hex, length) { | ||
"use strict"; | ||
|
||
var str = hex.length % 2 ? "0" + hex : hex; | ||
|
||
if(length){ | ||
str = (repeat("00", length) + str); | ||
str = str.substr(str.length - length * 2); | ||
} | ||
|
||
for (var bytes = [], c = 0; c < str.length; c += 2) | ||
bytes.push(parseInt(str.substr(c, 2), 16)); | ||
return bytes; | ||
}; | ||
|
||
var padBytes = function (array, length) { | ||
if (length === undefined) { | ||
length = fieldSize; | ||
} | ||
|
||
for (var i = 0; array.length < length; ++i) { | ||
array.unshift(0); | ||
} | ||
|
||
return array; | ||
}; | ||
|
||
var shuffleArray = function (array) { | ||
var counter = array.length, temp, index; | ||
|
||
// While there are elements in the array | ||
while (counter > 0) { | ||
// Pick a random index | ||
index = Math.floor(Math.random() * counter); | ||
|
||
// Decrease counter by 1 | ||
counter--; | ||
|
||
// And swap the last element with it | ||
temp = array[counter]; | ||
array[counter] = array[index]; | ||
array[index] = temp; | ||
} | ||
|
||
return array; | ||
}; | ||
|
||
var getSharedSecret = function (privateKey, publicKey) { | ||
var sharedSecret = padBytes(privateKey.derive(ECcrypt.keyPair(publicKey).getPublic()).toArray()); | ||
return sjcl.codec.bytes.fromBits(sjcl.hash.sha256.hash(sjcl.codec.bytes.toBits(sharedSecret))); | ||
}; | ||
|
||
var xorBytes = function (a, b) { | ||
if (a.length != b.length) { | ||
throw new Error("Длины не сходятся"); | ||
} | ||
|
||
for (var i in a) { | ||
a[i] ^= b[i]; | ||
} | ||
|
||
return a; | ||
}; | ||
|
||
var appendBuffer = function(buffer1, buffer2) { | ||
"use strict"; | ||
|
||
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength); | ||
tmp.set(buffer1, 0); | ||
tmp.set(buffer2, buffer1.byteLength); | ||
return tmp; | ||
}; |
Oops, something went wrong.