Fix Objective-C implementation, it has different result comparing to others.

Division operator and modulo operator have the same priority. So the result of "i % sizeof(key)/sizeof(unichar)" is the same as "(i % sizeof(key)) / sizeof(unichar)". But expected result should be "i % (sizeof(key)/sizeof(unichar))".
This commit is contained in:
Grey Lee 2017-03-23 11:58:48 +08:00 committed by GitHub
parent 88e695bebd
commit 15d89e91e8
1 changed files with 1 additions and 1 deletions

View File

@ -19,7 +19,7 @@
for(int i = 0; i < input.length; i++) {
unichar c = [input characterAtIndex:i];
c ^= key[i % sizeof(key)/sizeof(unichar)];
c ^= key[i % (sizeof(key)/sizeof(unichar))];
[output appendString:[NSString stringWithFormat:@"%C", c]];
}