Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / test_inplace_xor.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import crypto
16
17 var xor_base = b"qwertyuiopasdfghjklzxcvbnm"
18 var xor_base_2 = xor_base.clone
19 var xor_base_3 = xor_base.clone
20 var key = b" "
21 var key2 = b" \x00"
22
23 var key_cstr = key.items
24 var xb_cstr = xor_base.items
25
26 xb_cstr.xor(key_cstr, 5, 1)
27
28 print xb_cstr.to_s_with_length(xor_base.length)
29
30 xb_cstr.xor(key_cstr, xor_base.length, 1)
31
32 print xb_cstr.to_s_with_length(xor_base.length)
33
34 var xb_cstr2 = xor_base_2.items
35 var xb_cstr3 = xor_base_3.items
36 var key2_cstr = key2.items
37
38 xb_cstr2.xor(key2_cstr, xor_base_2.length, 2, 1)
39
40 xb_cstr3.xor(key2_cstr, xor_base_3.length, 2)
41
42 print xb_cstr2.to_s_with_length(xor_base_2.length)
43 print xb_cstr3.to_s_with_length(xor_base_3.length)