Flickyyy

Funcction of shifring file

Aug 4th, 2020 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #pragma once
  2. #include <fstream>
  3. #include <string>
  4.  
  5. void CreateFile(const std::string& path) noexcept {
  6.     std::ofstream file(path, std::ios_base::app);
  7.     file.close();
  8. }
  9.  
  10. bool ShifrFile(const std::string& path,
  11.     uint8_t(*const ShifrFunc)(const uint8_t)) noexcept {
  12.     std::fstream file(path, std::ios_base::binary
  13.         | std::ios_base::in | std::ios_base::out);
  14.  
  15.     if (!file.is_open()) return false;
  16.  
  17.     for (size_t i = 0; file; ++i)
  18.     {
  19.         uint8_t v = ShifrFunc(file.seekg(i).get());
  20.         file.seekp(i).put(v);
  21.     }
  22.  
  23.     file.close();
  24.     return true;
  25. }
Add Comment
Please, Sign In to add comment