@@ -17,11 +17,11 @@ std::vector<uint8_t> ReadAllBytes(const std::string &path)
1717 try
1818 {
1919 std::ifstream inStream (path, std::ios::binary | std::ios::ate);
20- auto fileSize = ( size_t ) inStream.tellg ();
20+ auto fileSize = static_cast < size_t >( inStream.tellg () );
2121 auto fileBytes = std::vector<uint8_t >(fileSize);
2222
2323 inStream.seekg (0 , std::ios::beg);
24- inStream.read (( char *) &fileBytes[0 ], fileSize);
24+ inStream.read (reinterpret_cast < char *>( &fileBytes[0 ]) , fileSize);
2525 inStream.close ();
2626
2727 return fileBytes;
@@ -34,7 +34,8 @@ std::vector<uint8_t> ReadAllBytes(const std::string &path)
3434}
3535
3636// / <summary>
37- // / Decrypts the specified cipherText into <paramref name="out_plaintext"/> using the given key and initialization vector.
37+ // / Decrypts the specified cipherText into <paramref name="out_plaintext"/>
38+ // / using the given key and initialization vector.
3839// / </summary>
3940// / <param name="cipherText">Encrypted bytes to decrypt.</param>
4041// / <param name="key">Key used for decryption.</param>
@@ -63,7 +64,14 @@ bool Decrypt(
6364 return false ;
6465 }
6566
66- is_successful = EVP_DecryptUpdate (ctx, &out_plaintext[0 ], &plaintext_length, &cipherText[0 ], (int )cipherText.size ());
67+ is_successful = EVP_DecryptUpdate (
68+ ctx,
69+ &out_plaintext[0 ],
70+ &plaintext_length,
71+ &cipherText[0 ],
72+ static_cast <int >(cipherText.size ())
73+ );
74+
6775 if (is_successful == false )
6876 {
6977 std::cerr << " EVP_DecryptUpdate - FAILED" << std::endl;
@@ -107,7 +115,16 @@ bool GetKeys(
107115 out_key.resize (cipher->key_len );
108116 out_initialization_vector.resize (cipher->iv_len );
109117
110- auto result = EVP_BytesToKey (cipher, md, &salt[0 ], &source_bytes[0 ], (int )source_bytes.size (), kIterationCount , &out_key[0 ], &out_initialization_vector[0 ]);
118+ auto result = EVP_BytesToKey (
119+ cipher,
120+ md,
121+ &salt[0 ],
122+ &source_bytes[0 ],
123+ static_cast <int >(source_bytes.size ()),
124+ kIterationCount ,
125+ &out_key[0 ],
126+ &out_initialization_vector[0 ]
127+ );
111128 return result > 0 ;
112129}
113130
@@ -126,7 +143,7 @@ std::vector<uint8_t> MangleData(const std::vector<uint8_t> &data_to_mangle)
126143 auto mangled_character = ((index + 2 ) * mangled_data[index]) % 128 ;
127144 if (mangled_character != 0 )
128145 {
129- mangled_data[index] = ( uint8_t ) mangled_character;
146+ mangled_data[index] = static_cast < uint8_t >( mangled_character) ;
130147 }
131148 }
132149
@@ -157,7 +174,7 @@ std::string GetMachineGuid()
157174 if (result != ERROR_SUCCESS)
158175 {
159176 RegCloseKey (key_handle);
160- std::cerr << " RegQueryValueEx - FAILED\n " << std::endl;
177+ std::cerr << " RegQueryValueEx - FAILED" << std::endl;
161178 return " " ;
162179 }
163180
@@ -166,7 +183,7 @@ std::string GetMachineGuid()
166183 if (result != ERROR_SUCCESS)
167184 {
168185 RegCloseKey (key_handle);
169- std::cerr << " RegQueryValueEx - FAILED\n " << std::endl;
186+ std::cerr << " RegQueryValueEx - FAILED" << std::endl;
170187 return " " ;
171188 }
172189
@@ -186,11 +203,11 @@ std::string GetPathToUserPreferencesBag()
186203
187204 // Resize our container to hold the environment variable
188205 std::vector<int8_t > path (1 );
189- auto required_path_length = GetEnvironmentVariableA (kEnvironmentVariable .c_str (), ( LPSTR) &path[0 ], 0 );
206+ auto required_path_length = GetEnvironmentVariableA (kEnvironmentVariable .c_str (), reinterpret_cast < LPSTR>( &path[0 ]) , 0 );
190207 path.resize (required_path_length);
191208
192209 // Get the actual environment variable
193- GetEnvironmentVariableA (kEnvironmentVariable .c_str (), ( LPSTR) &path[0 ], ( DWORD) path.size ());
210+ GetEnvironmentVariableA (kEnvironmentVariable .c_str (), reinterpret_cast < LPSTR>( &path[0 ]), static_cast < DWORD>( path.size () ));
194211
195212 // GetEnvironmentVariableA will add a null character in at the end, exclude it
196213 auto local_app_data_path = std::string (path.begin (), path.end () - 1 );
0 commit comments