-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase64Test.zok
32 lines (27 loc) · 4.61 KB
/
base64Test.zok
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
from "./base64" import fromBase64;
def testDifferentPaddings() -> bool {
// This tests conversion with different padding lengths (v1 needs no padding, v2 needs == for padding, v3 needs = for padding)
// Test on "Many hands make light work."
u8[27] v1 = fromBase64::<36,27>([84,87,70,117,101,83,66,111,89,87,53,107,99,121,66,116,89,87,116,108,73,71,120,112,90,50,104,48,73,72,100,118,99,109,115,117]);
// Test on "Many hands make light work.."
u8[30] v2 = fromBase64::<40,30>([84,87,70,117,101,83,66,111,89,87,53,107,99,121,66,116,89,87,116,108,73,71,120,112,90,50,104,48,73,72,100,118,99,109,115,117,76,103,61,61]);
// Test on "Many hands make light work..."
u8[30] v3 = fromBase64::<40,30>([84,87,70,117,101,83,66,111,89,87,53,107,99,121,66,116,89,87,116,108,73,71,120,112,90,50,104,48,73,72,100,118,99,109,115,117,76,105,52,61]);
assert(v1 == [77,97,110,121,32,104,97,110,100,115,32,109,97,107,101,32,108,105,103,104,116,32,119,111,114,107,46]);
assert(v2 == [77,97,110,121,32,104,97,110,100,115,32,109,97,107,101,32,108,105,103,104,116,32,119,111,114,107,46,46,0,0]);
assert(v3 == [77,97,110,121,32,104,97,110,100,115,32,109,97,107,101,32,108,105,103,104,116,32,119,111,114,107,46,46,46,0]);
return true;
}
def main() -> bool {
bool a = testDifferentPaddings();
return true;
}
// def googleJWTConvert() -> u8[660] {
// u8[660] out = fromBase64::<880,660>([101,121,74,104,98,71,99,105,79,105,74,83,85,122,73,49,78,105,73,115,73,109,116,112,90,67,73,54,73,106,103,50,77,84,89,48,79,87,85,48,78,84,65,122,77,84,85,122,79,68,78,109,78,109,73,53,90,68,85,120,77,71,73,51,89,50,81,48,90,84,107,121,77,106,90,106,77,50,78,107,79,68,103,105,76,67,74,48,101,88,65,105,79,105,74,75,86,49,81,105,102,81,46,101,121,74,112,99,51,77,105,79,105,74,104,89,50,78,118,100,87,53,48,99,121,53,110,98,50,57,110,98,71,85,117,89,50,57,116,73,105,119,105,89,88,112,119,73,106,111,105,77,106,85,48,79,84,103,48,78,84,65,119,78,84,89,50,76,84,78,120,97,88,77,49,78,71,49,118,90,109,86,110,78,87,86,107,98,50,100,104,100,87,112,121,99,68,104,121,89,106,100,119,89,110,65,53,99,88,82,117,76,109,70,119,99,72,77,117,90,50,57,118,90,50,120,108,100,88,78,108,99,109,78,118,98,110,82,108,98,110,81,117,89,50,57,116,73,105,119,105,89,88,86,107,73,106,111,105,77,106,85,48,79,84,103,48,78,84,65,119,78,84,89,50,76,84,78,120,97,88,77,49,78,71,49,118,90,109,86,110,78,87,86,107,98,50,100,104,100,87,112,121,99,68,104,121,89,106,100,119,89,110,65,53,99,88,82,117,76,109,70,119,99,72,77,117,90,50,57,118,90,50,120,108,100,88,78,108,99,109,78,118,98,110,82,108,98,110,81,117,89,50,57,116,73,105,119,105,99,51,86,105,73,106,111,105,77,84,65,119,78,122,103,51,79,68,81,48,78,68,99,122,77,84,99,121,77,106,107,52,78,84,81,122,73,105,119,105,90,87,49,104,97,87,119,105,79,105,74,117,89,87,53,104,97,50,53,112,97,71,70,115,81,71,100,116,89,87,108,115,76,109,78,118,98,83,73,115,73,109,86,116,89,87,108,115,88,51,90,108,99,109,108,109,97,87,86,107,73,106,112,48,99,110,86,108,76,67,74,104,100,70,57,111,89,88,78,111,73,106,111,105,100,68,90,113,86,108,57,66,90,48,70,121,84,71,112,117,76,88,70,86,83,108,78,53,98,85,120,111,90,121,73,115,73,109,53,104,98,87,85,105,79,105,74,79,89,87,53,104,97,121,66,79,97,87,104,104,98,67,66,76,97,71,70,115,99,50,69,105,76,67,74,119,97,87,78,48,100,88,74,108,73,106,111,105,97,72,82,48,99,72,77,54,76,121,57,115,97,68,77,117,90,50,57,118,90,50,120,108,100,88,78,108,99,109,78,118,98,110,82,108,98,110,81,117,89,50,57,116,76,50,69,118,81,85,70,85,87,69,70,75,100,122,82,110,77,86,65,51,85,70,90,85,83,50,90,87,85,85,49,108,100,70,100,116,85,86,103,120,81,108,78,118,87,106,108,80,87,84,82,86,85,87,116,76,99,106,100,115,84,68,81,57,99,122,107,50,76,87,77,105,76,67,74,110,97,88,90,108,98,108,57,117,89,87,49,108,73,106,111,105,84,109,70,117,89,87,115,103,84,109,108,111,89,87,119,105,76,67,74,109,89,87,49,112,98,72,108,102,98,109,70,116,90,83,73,54,73,107,116,111,89,87,120,122,89,83,73,115,73,109,120,118,89,50,70,115,90,83,73,54,73,109,86,117,73,105,119,105,97,87,70,48,73,106,111,120,78,106,85,120,77,122,81,53,77,106,99,122,76,67,74,108,101,72,65,105,79,106,69,50,78,84,69,122,78,84,73,52,78,122,77,115,73,109,112,48,97,83,73,54,73,106,65,51,78,84,85,52,79,68,100,108,79,84,73,51,77,122,65,49,90,84,89,48,89,50,69,52,77,87,86,104,77,122,69,51,89,106,89,120,90,71,81,120,89,87,74,106,78,87,70,105,90,106,103,105,102]);
// return out;
// }
// Code to get payload from a JWT (i.e., shift it by two bytes to account for . modifying base64 encoding)
// u8[660] stillUgly = googleJWTConvert();
// bool[660*8] boolified = u8_array_to_bool_array(stillUgly);
// bool[660*8] shifted = [...boolified[2..5280], false, false];
// return bool_array_to_u8_array(shifted);