Skip to content

Commit

Permalink
Depend only on min_const_generics (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualX authored Oct 26, 2020
1 parent bf51ed7 commit e793b2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ pub const fn keystream<const LEN: usize>(key: u32) -> [u8; LEN] {
#[inline(always)]
pub const fn obfuscate<const LEN: usize>(s: &[u8], k: &[u8; LEN]) -> [u8; LEN] {
if s.len() != LEN {
panic!("input string len not equal to key stream len");
// panic!("input string len not equal to key stream len");
loop { }
}
let mut data = [0u8; LEN];
let mut i = 0usize;
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Compiletime string constant obfuscation.
*/

#![allow(incomplete_features)]
#![feature(const_fn, const_generics, const_panic)]
#![feature(min_const_generics)]
#![no_std]

use core::{char, fmt, str};
Expand Down Expand Up @@ -150,7 +149,8 @@ pub const fn wide_len(s: &str) -> usize {
i += 4;
}
else {
unimplemented!()
// unimplemented!()
loop { }
};
len += if chr >= 0x10000 { 2 } else { 1 };
}
Expand Down Expand Up @@ -182,7 +182,8 @@ pub const fn wide<const LEN: usize>(s: &str) -> [u16; LEN] {
i += 4;
}
else {
unimplemented!()
// unimplemented!()
loop { }
};
if chr >= 0x10000 {
data[j + 0] = (0xD800 + (chr - 0x10000) / 0x400) as u16;
Expand Down
3 changes: 2 additions & 1 deletion src/words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub const fn keystream<const LEN: usize>(key: u32) -> [u16; LEN] {
/// Obfuscates the input string and given key stream.
pub const fn obfuscate<const LEN: usize>(s: &[u16], k: &[u16; LEN]) -> [u16; LEN] {
if s.len() != LEN {
panic!("input string len not equal to key stream len");
// panic!("input string len not equal to key stream len");
loop { }
}
let mut data = [0u16; LEN];
let mut i = 0usize;
Expand Down

0 comments on commit e793b2f

Please sign in to comment.