28 lines
1.1 KiB
Haskell
28 lines
1.1 KiB
Haskell
module Main where
|
|
|
|
import qualified Data.ByteString as BS
|
|
import Numeric (showHex)
|
|
import Data.Word (Word8)
|
|
import Qmc.QmcDecryptor (decryptMflac)
|
|
|
|
fmtHex :: Word8 -> String
|
|
fmtHex b = let h = showHex (fromIntegral b :: Int) "" in replicate (2 - length h) '0' ++ h
|
|
|
|
main :: IO ()
|
|
main = do
|
|
putStrLn "QMC Haskell — decrypt f:/qqmusic_debug/test_raw.mflac"
|
|
ekey <- readFile "f:/qqmusic_debug/test_ekey.txt"
|
|
let ekey' = filter (`notElem` "\n\r") ekey
|
|
dataBs <- BS.readFile "f:/qqmusic_debug/test_raw.mflac"
|
|
case decryptMflac dataBs ekey' of
|
|
Left err -> putStrLn $ "ERROR: " ++ err
|
|
Right out -> do
|
|
let header = BS.take 4 out
|
|
if header == BS.pack [0x66, 0x4C, 0x61, 0x43]
|
|
then do
|
|
putStrLn $ "OK: " ++ show (BS.length out) ++ " bytes, fLaC header verified"
|
|
BS.writeFile "f:/qqmusic_debug/decoded_haskell.flac" out
|
|
else do
|
|
putStrLn $ "BAD HEADER: " ++ concatMap fmtHex (BS.unpack header)
|
|
BS.writeFile "f:/qqmusic_debug/decoded_haskell_bad.flac" out
|