Skip to content

Instantly share code, notes, and snippets.

@yosupo06 yosupo06/decrypt.d Secret
Created Dec 9, 2015

Embed
What would you like to do?
import std.process;
import std.stdio, std.file;
import std.conv;
import std.ascii;
import std.algorithm;
char[] cry(char[] s) {
return execute(["./cryptooo", s]).output.dup;
}
int same(char[] s, char[] t) {
auto n = cast(int)(min(s.length, t.length));
foreach (i; 0..n) {
if (s[i] != t[i]) return i;
}
return n;
}
int main() {
string mp = letters ~ digits ~ "!@#$%^&*()-_=+\\|`~[{]};:'\",<.>/?";
int n = 32;
char[] s = new char[](n);
s[] = 'a';
char[] res = "Encrypted(44): waUqjjDGnYxVyvUOLN8HquEO0J5Dqkh/zr/3KXJCEnw=".dup;
foreach (i; 0..n-1) {
char[] s2;
int ma = -1;
foreach (c; mp) {
foreach (d; mp) {
s[i] = c;
s[i+1] = d;
auto t = cry(s);
int u = same(t, res);
if (ma < u) {
ma = u;
s2 = s.dup;
}
}
}
s = s2.dup;
writeln(s, " ", cry(s));
}
writeln(s);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.