This commit is contained in:
2026-04-21 09:28:37 +02:00
parent 381cabeda4
commit 3f92778516
+11 -10
View File
@@ -188,24 +188,25 @@ fn e(byte1: u8, byte2: u8) -> [u8; 8] {
}
/// BP.
/// input bits numbered: 12345678 (bit 1 MSB),
/// output: 38467215.
/// input bits numbered: 01234567 (bit 0 LSB),
/// output: 37612405.
fn bp(x: u8) -> u8 {
let bit = |pos: u8| -> u8 { (x >> (8 - pos)) & 1 };
let bit = |pos: u8| -> u8 { (x >> pos) & 1 };
(bit(3) << 7)
| (bit(8) << 6)
| (bit(4) << 5)
| (bit(6) << 4)
| (bit(7) << 3)
| (bit(2) << 2)
| (bit(1) << 1)
| (bit(7) << 6)
| (bit(6) << 5)
| (bit(1) << 4)
| (bit(2) << 3)
| (bit(4) << 2)
| (bit(0) << 1)
| bit(5)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tea3_from_c::Tea3FromC;
use crate::Lfsr;
#[test]
@@ -270,7 +271,7 @@ mod tests {
fn test_bp() {
let x = 0b10110010;
let result = bp(x);
assert_eq!(result, 0b10101010);
assert_eq!(result, 0b01010101);
}
#[test]