-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.gpsl
51 lines (44 loc) · 1.32 KB
/
client.gpsl
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
#[server(ip = "172.25.5.189:8080")]
fn encrypt_add(a: Vec<eep>) $(accept[StdOut]) {
println("");
println("集計開始");
let r: eep = a[0];
println("1人目: " + a[0]);
let a_length = length(a);
for (let i = 1; i < a_length; i += 1) {
println((i + 1) + "人目: " + a[i]);
r = r + a[i];
}
println("");
return r;
}
fn main() {
let a: Vec<U512> = vec(to_u512(0));
let b: Vec<eep> = vec(encrypt(0));
print("人数を入力してください > ");
let n = to_num(read_line());
for (let i = 0; i < (n - 1); i += 1) {
a = push(a, to_u512(0));
b = push(b, encrypt(0));
}
println("賛成なら1, 反対なら0を入力してください");
for (let i = 0; i < n; i += 1) {
print((i + 1) + "人目 > ");
let in = to_u512(read_line());
if (in == to_u512(1)) || (in == to_u512(0))
a[i] = in;
else {
println("1か0を入力してください");
i -= 1;
}
}
println("暗号化してサーバーへ送信します...");
for (let i = 0; i < n; i += 1) {
b[i] = encrypt(a[i]);
}
let r = encrypt_add(b);
println("復号します...");
let result = decrypt(r);
println("賛成の合計は" + result + "です。");
write("result.txt", result);
}