pull/1/head
Avril 5 years ago
parent 87bc9a2316
commit f143d1cd2c
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -234,7 +234,7 @@
The kana algorithm is a 16-bit block digest that works as follows:
- The most and least significant 8 bits are each seperated into /Stage 0/ and /Stage 1/ each operating on the first and second byte respectively.
- Stage 0:
1. The byte is sign tested (bitwise ~AND~ =0x80=), store this as a boolean in /sign0/.
1. The byte is sign tested (bitwise ~AND~ =0x80=), store this as a boolean in /sign0/ (Negative becomes =1=, positive becomes =0=.)
2. The valid first character range is looked up using the result of the sign test (either 0 or 1), store the range in /range/, and the slice ~KANA~ taken from the range in /kana/.
3. The first index is calculated as the unsigned first byte modulo the size (exclusive) of /range/. Store this as /index/.
4. Compute the value of the first byte bitwise ~XOR~ the second byte, store this as /index1/.

@ -20,7 +20,7 @@ impl Digest {
return d;
}
let sign0 = unsafe { *reinterpret::value::<i8>(from) < 0 };
let sign0 = from[0] & 0x80 != 0;//unsafe { *reinterpret::value::<i8>(from) < 0 };
let range = &map::KANA_SIGN[sign0 as usize];
let kana = &map::KANA[range.clone()];
let oneesan = usize::from(from[0]) % kana.len();

Loading…
Cancel
Save