encrypt password and account number

* the encryption uses a unique machine key, this means that if anyone steals config.otml with a saved password,
he will not be able to decrypt the password without the machine UUID key
* the encrypt uses a simple XOR encryption method, encoded with base64 and adler32 summing
This commit is contained in:
Eduardo Bart
2012-06-04 09:38:15 -03:00
parent 296f2a17c4
commit e5000fa577
13 changed files with 249 additions and 32 deletions

View File

@@ -28,7 +28,7 @@
namespace stdext {
inline uint32 generate_adler_checksum(uint8 *buffer, uint16 size) {
inline uint32 adler32(const uint8 *buffer, uint16 size) {
register uint32 a = 1, b = 0, tlen;
while(size > 0) {
tlen = size > 5552 ? 5552 : size;
@@ -57,9 +57,9 @@ inline uint32 to_power_of_two(uint32 v) {
return r;
}
inline uint16 readLE16(uchar *addr) { return (uint16)addr[1] << 8 | addr[0]; }
inline uint32 readLE32(uchar *addr) { return (uint32)readLE16(addr + 2) << 16 | readLE16(addr); }
inline uint64 readLE64(uchar *addr) { return (uint64)readLE32(addr + 4) << 32 | readLE32(addr); }
inline uint16 readLE16(const uchar *addr) { return (uint16)addr[1] << 8 | addr[0]; }
inline uint32 readLE32(const uchar *addr) { return (uint32)readLE16(addr + 2) << 16 | readLE16(addr); }
inline uint64 readLE64(const uchar *addr) { return (uint64)readLE32(addr + 4) << 32 | readLE32(addr); }
inline void writeLE16(uchar *addr, uint16 value) { addr[1] = value >> 8; addr[0] = (uint8)value; }
inline void writeLE32(uchar *addr, uint32 value) { writeLE16(addr + 2, value >> 16); writeLE16(addr, (uint16)value); }

View File

@@ -161,7 +161,7 @@ inline std::string date_time_string() {
}
/// Convert decimal to hexadecimal
inline std::string dec_to_hex(unsigned int num) {
inline std::string dec_to_hex(uint64 num) {
std::string str;
std::ostringstream o;
o << std::hex << num;
@@ -170,8 +170,8 @@ inline std::string dec_to_hex(unsigned int num) {
}
/// Convert hexadecimal to decimal
inline unsigned int hex_to_dec(const std::string& str) {
unsigned int num;
inline uint64 hex_to_dec(const std::string& str) {
uint64 num;
std::istringstream i(str);
i >> std::hex >> num;
return num;