-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
95 lines (76 loc) · 13.8 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var $ = function( id ) { return document.getElementById( id ); };
function focusinput(){
$("input").focus();
$("input").value = "SHA 2017"
hash();
}
function changeFontSize(){
$("input").style.fontSize = $("slider").value+"px";
$("input").style.height = $("slider").value*1.7+"px";
}
function toggleLeftArrow(){
toggleVisibility("arrow_left_up");
toggleVisibility("arrow_left_down");
}
function toggleRightArrow(){
toggleVisibility("arrow_right_up");
toggleVisibility("arrow_right_down");
}
function toggleVisibility(elementName){
(document.getElementById(elementName).style.display == 'none') ?document.getElementById(elementName).style.display='block' : document.getElementById(elementName).style.display='none'
}
function hash(){
output = sha1($("input").value);
$("SHA1_normal").value = output;
$("SHA1_uppercase").value = output.toUpperCase();
$("SHA1_split").value = splitper(output,2,":");
// to make this site more colorful and happy, we convert the hex we get to HTML colors following the infamous freedom flag :)
flag = "#" + splitper(output,6," #");
flagcolors = flag.split(" "); // a flag is postfixed with remaining, not html safe colors, such as + C0
if (flagcolors[flagcolors.length-1].length < 7){
flagcolors[flagcolors.length-1] = flagcolors[flagcolors.length-1].replace("#","+");
}
flag = flagcolors.join(" ");
$("SHA1_freedomflag").value = flag;
var happyColors = "";
asciiNeeded = (flagcolors[flagcolors.length-1].length < 7);
if (flagcolors.length > 1) {
for (j=0;j<flagcolors.length;j++){
if (j < flagcolors.length-2) {
happyColors += "<span class='flagblock' style='background-color: "+flagcolors[j]+"'> </span>";
} else {
if (asciiNeeded){
happyColors += "<span class='flagblock' style='background-color: "+flagcolors[j]+"'><span class='flagcode'>" +flagcolors[(j+1)]+ "</span></span>";
break;
} else {
happyColors += "<span class='flagblock' style='background-color: "+flagcolors[j]+"'> </span>";
}
}
}
}
$("SHA1_flag").innerHTML = happyColors;
$("logo").innerHTML = happyColors;
$("textcode").innerHTML = flagcolors[flagcolors.length-1];
$("logotext").innerHTML = $("input").value.substring(0,6);
}
// with 11061 spaces, you have SHA( *11061) 2017 that has a flag with +2017
// also one at 26832 (happy colors), 30439, , in the 64000 in lowercase.
function shabrute(){
padding = "";
answer = "";
skip = 1;
while (1){
padding += " "
bla = sha1("SHA" + padding + "2017")
answer = bla.substring(36)
if (answer == "2017")
alert(padding.length)
}
}
function splitper(value, n, separator){
var returnValue = "";
for (j=0; j<value.length; j += n){
returnValue += value.substr(j,n) + separator;
}
return returnValue.substr(0,returnValue.length-(separator.length));
}