Skip to content

Commit

Permalink
feat: 鍵長を指定できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
xryuseix committed Jul 10, 2021
1 parent 45d791c commit 5e7458b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Binary file modified cubing/out/cipher_text.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion cubing/out/enc_key.key
Original file line number Diff line number Diff line change
@@ -1 +1 @@
200021202021112021000100022002010010202102121112001221111220111000122002100122012211201100211201220110121011012202022121211210201221220201002022120202201000110122202111020210202112211101001011222110212121110021221112222210200200011121012101221221120200211102101200200022001211220112221001122000010100
210212202010221202020201200211022101200201100102202201011100122110010000001022102110101220000211021121121122010200122110201111221100211022201100212111102112121210022001112011110200002002222202011012210111121000101200100022212220110000022222121000102110120121202012002122210201120212111201100120020010212021101212212000100121022210012220101212110002010121021121210220121022021210002200002212111112002112021200210100102020001020011112000201110121100120210200012111022012001022120201211201220002210021110010002010022121200210021121202010221110220210010220200010221012021222012022210120212221220110102222020012200101111212221220010021200200020100211010210000001102221002221110102220120211220112011011021010020001012210012110212111202222012010002202202220002200220110220022222121112000120202112000221221012121000110011100212101022221201120101112110012220012212012000012122020220010012202010001220010202011201120120220020212201100202110000211220122111121010102221211212211012012000200211002122110210022222222202121000201101120212211120001211122210102112110222200020210210112202012101102210121200101020221101000220201220112210001102001012220122120001122101112021022101022201112012122210111220010011201120200000202122021200200002010111202122020020200220202021001200222001111112210012001111010001101211111022221021000221010020110221202000102021222110020102110122222210122020011002012101222102201100201020221220110020221001101001222011111022110002221001220211011110000021010212012222022121021201210102100120010212010101121200101212012020011020201021020112120221001100112201212112221221000200212211120120020201202200220200010102020121202121011102001012022111121012012122120120011122111020212021102201201021010210000222200101102110012120101201012211101101020111211210002021111010001201220002121022011201112202211000111021012201211122211211222000201210201110002002222012022100202000022102022100102210210202022021021121200110201000002222220020121021020112102101212201222110202201022201002122202202011101122200220202012100002002202100210202220221020200211000001212211111022001001200212000110011020210022111212222222200122110221020200000001220110010112020021210020222202101110120020011202211221001220012001122210001022000210011012002110021210020221120200222210011000120001100102121211122120010121221010212120102002201100112121011201112010010201011212121102012010022120122120200212020110211010002202022010200112021110201012111020121202020222220112002020122222202110001102000202200002011102012000010200112010022112221202010002112001210011120221000110022202222220122010121110022210222001100000111001210102220122100020020012101211010200000212001110210000200220120112022200112122001001102200021002102011001010210211101200021221111001002020121012110202222212012220002210010222211101222110210211221012201222110102020200121011120221111201021001020202011112001210211120022022120212222100221021022001202202202121212210221201121201021220011001010122022221110112121202100221110022112020120010121100202121000211212111001222110201
Binary file modified cubing/out/mask1.key
Binary file not shown.
4 changes: 2 additions & 2 deletions cubing/out/mask2.key
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Xz&:n5> dG`jJMc)]kM1^Be
d>fu5^
OY_j;K5__5l6,c$ABH{SBd<[
T_M3"
14 changes: 11 additions & 3 deletions cubing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ fn main() -> Result<()> {
Some(key_file) => {
key::key_convert(read_file(key_file, Some("key_text".to_string())).unwrap())
}
_ => key::key_generate(100),
_ => key::key_generate(
stdin(Some("key length".to_string()))
.unwrap()
.parse::<usize>()
.unwrap(),
),
};
let (cipher_text, mask1, mask2) = cubingmode::encrypt(encode::str_to_arr(plain_text), &key);
write_file(
Expand All @@ -73,7 +78,7 @@ fn main() -> Result<()> {
}?;
let key = match opts.key_file.clone() {
Some(file) => key::key_convert(read_file(file, Some("key_text".to_string())).unwrap()),
_ => key::key_generate(100),
_ => key::key_convert(stdin(Some("key".to_string())).unwrap()),
};
let mask1 = match opts.mask1_file {
Some(file) => read_file(file, Some("mask1".to_string())),
Expand All @@ -90,7 +95,10 @@ fn main() -> Result<()> {
&key,
);
write_file(plain_text.clone(), "plain_text.txt")?;
println!("decrypted: \n{}", (&plain_text[0..cmp::min(100, plain_text.len())]).to_string());
println!(
"decrypted: \n{}",
(&plain_text[0..cmp::min(100, plain_text.len())]).to_string()
);
}
Ok(())
}
Expand Down

0 comments on commit 5e7458b

Please sign in to comment.