@@ -36,7 +36,7 @@ encryptor_singletone& encryptor_singletone::instance()
3636
3737keyfile_format::encrypted_data encryptor_singletone::encrypt_keydata (
3838 keyfile_format::cipher_etype etype,
39- const std::string & key,
39+ const std::wstring & key,
4040 const std::string& keydata)
4141{
4242 keyfile_format::encrypted_data enc_data;
@@ -52,7 +52,8 @@ keyfile_format::encrypted_data encryptor_singletone::encrypt_keydata(
5252 // I cannot figure out the exact reason what exactly is wrong with the key (it is need to debug asm function
5353 // to find out reason)
5454 // The solution (from lib/fc) is to create hash from password string and encrypt data on hash key
55- auto key_hash = fc::sha512::hash (key);
55+ const char * key_data = reinterpret_cast <const char *>(key.data ());
56+ auto key_hash = fc::sha512::hash (key_data, key.size ()* sizeof (std::wstring::value_type));
5657
5758 if (1 != EVP_EncryptInit_ex (m_ctx, get_cipher (etype), NULL , reinterpret_cast <const uint8_t *>(&key_hash),
5859 reinterpret_cast <const uint8_t *>(enc_data.iv .c_str ())))
@@ -81,7 +82,7 @@ keyfile_format::encrypted_data encryptor_singletone::encrypt_keydata(
8182 return enc_data;
8283}
8384
84- std::string encryptor_singletone::decrypt_keydata (const std::string & key, keyfile_format::encrypted_data& data)
85+ std::string encryptor_singletone::decrypt_keydata (const std::wstring & key, keyfile_format::encrypted_data& data)
8586{
8687 int decr_length = 0 ;
8788 int length = 0 ;
@@ -98,7 +99,8 @@ std::string encryptor_singletone::decrypt_keydata(const std::string& key, keyfil
9899 // I cannot figure out the exact reason what exactly is wrong with the key (it is need to debug asm function
99100 // to find out reason)
100101 // The solution (from lib/fc) is to create hash from password string and encrypt data on hash key
101- auto key_hash = fc::sha512::hash (key);
102+ const char * key_data = reinterpret_cast <const char *>(key.data ());
103+ auto key_hash = fc::sha512::hash (key_data, key.size ()* sizeof (std::wstring::value_type));
102104
103105 if (1 != EVP_DecryptInit_ex (m_ctx, get_cipher (data.cipher_type ), NULL , reinterpret_cast <const uint8_t *>(&key_hash),
104106 reinterpret_cast <const uint8_t *>(data.iv .c_str ())))
0 commit comments