明文:THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 密文:WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
Finished dev [unoptimized + debuginfo] target(s)in 0.05sRunning `F:\learn\rustlearn\learn56\target\debug\learn56.exe`
源字符串: At MIT, pushing the boundaries of knowledge and possibility is our joyful obsession, and we celebrate fundamental discoveries and practical applications alike. As educators, we also value research as a potent form of learning by doing. Through MIT’s Undergraduate Research Opportunities Program (UROP(opens in new window)), more than 85% of undergraduates enrich their education through engaging in frontline, faculty-led research.
凱撒密碼加密
加密結果:M€,YU`8,|?tuzs,€tq,n{?zpm~uq,{r,wz{?xqpsq,mzp,|{unuxu€
,u,{?~,v{
r?x,{nqu{z8,mzp,?q,oqxqn~m€q,r?zpmyqz€mx,puo{?q~uq,mzp,|~mo€uomx,m||xuom€u{z,mxuwq:,M,qp?om€{~8,?q,mx{,?mx?q,~qqm~ot,m,m,|{€qz€,r{~y,{r,xqm~zuzs,n
,p{uzs:,`t~{?st,YU`%,azpq~s~mp?m€q,^qqm~ot,[||{~€?zu€uq,\~{s~my,4a^[\4{|qz,uz,zq?,?uzp{?558,y{~q,€tmz,DA1,{r,?zpq~s~mp?m€q,qz~uot,€tqu~,qp?om€u{z,€t~{?st,qzsmsuzs,uz,r~{z€xuzq8,rmo?x€
9xqp,~qqm~ot:
凱撒密碼解密
解密結果:At MIT, pushing the boundaries of knowledge and possibility is our joyful obsession, and we celebrate fundamental discoveries and practical applications alike. As educators, we also value research as a potent form of learning by doing. Through MITs Undergraduate Research Opportunities Program (UROP(opens in new window)), more than 85% of undergraduates enrich their education through engaging in frontline, faculty-led research.------------------
(program exited with code: 0)請按任意鍵繼續. ..
use std::str;fn encrypt(s:&str,passwd:u8)->Vec<char>{let mut s_asc=Vec::new();for c in s.chars(){let mut ascii=c as u8;ascii=ascii+passwd;let c_new=ascii as char;s_asc.push(c_new);}s_asc
}
fn decrypt(s:String,passwd:u8)->Vec<char>{let mut s_asc=Vec::new();for c in s.chars(){let mut ascii=c as u8;ascii=ascii-passwd;let c_new=ascii as char;s_asc.push(c_new);}s_asc
}
fn main(){//&str是一個切片(&[u8]),它總是指向一個有效的UTF-8序列,并且可以用來查看String,就像&[T]是Vec的一個視圖一樣// 對只讀內存中分配的字符串的引用let str1:&'static str ="At MIT, pushing the boundaries of knowledge and possibility is our joyful obsession, and we celebrate fundamental discoveries and practical applications alike. As educators, we also value research as a potent form of learning by doing. Through MIT’s Undergraduate Research Opportunities Program (UROP(opens in new window)), more than 85% of undergraduates enrich their education through engaging in frontline, faculty-led research.";//let a = "abcdefghi";println!("源字符串: {}", str1);let password:u8=12;//密碼// 凱撒密碼,加密println!("凱撒密碼加密");let new_str1:Vec<char>=encrypt(&str1,password);let result_str1:String = new_str1.iter().collect();// new_str1.reverse();println!("加密結果:{}",result_str1); println!("凱撒密碼解密");let new_str2:Vec<char>=decrypt(result_str1,password);let result_str2:String = new_str2.iter().collect();println!("解密結果:{}",result_str2);}與50位技術專家面對面20年技術見證,附贈技術全景圖