Advertisement
Guest User

C++ Cypher

a guest
Apr 18th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void encrypt( std::string &iostr,int key){
  5. key %= 26;
  6. int ch;
  7. for(auto &it:iostr){
  8. ch = tolower(it) + key;
  9. if( ch > 'z' )
  10. ch -= 26;
  11. it = ch;}}
  12.  
  13. int main(){
  14. std::string source = "zebra";
  15. int key = 15;
  16. std::cout << source << std::endl;
  17. encrypt( source , key );
  18. std::cout << source << std::endl;
  19. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement