mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-23 07:37:46 +00:00
I ended up just stealing this from iolite, which in turn took it from Sapphire. I tried for a few hours to get a Rust Blowfish implementation going, but the one from Physis didn't work. I'll try again later.
30 lines
871 B
C++
30 lines
871 B
C++
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include "blowfish.h"
|
|
#include "wrapper.h"
|
|
|
|
// the contents of blowfish.cpp and it's headers are directly from sapphire server (which I believe is ripped from the game but with prep methods)
|
|
// https://github.com/SapphireServer/Sapphire/blob/master/src/common/Crypt/blowfish.cpp
|
|
// TODO: eventually get the lobby to work with the blowfish or blowfish_rs crate.
|
|
|
|
BYTE *blowfish_encode(BYTE *key, uint32_t keybytes, BYTE *pInput, DWORD lSize)
|
|
{
|
|
BlowFish blowfish;
|
|
blowfish.initialize(key, keybytes);
|
|
|
|
BYTE *pOutput = new BYTE[lSize];
|
|
blowfish.Encode(pInput, pOutput, lSize);
|
|
|
|
return pOutput;
|
|
}
|
|
|
|
BYTE *blowfish_decode(BYTE *key, uint32_t keybytes, BYTE *pInput, DWORD lSize)
|
|
{
|
|
BlowFish blowfish;
|
|
blowfish.initialize(key, keybytes);
|
|
|
|
BYTE *pOutput = new BYTE[lSize];
|
|
blowfish.Decode(pInput, pOutput, lSize);
|
|
|
|
return pOutput;
|
|
}
|