Recently in a cool dog music lyrics collection found that cool dog music lyrics directly browse are "garbled", I usually see the lyrics are LRC format text, this cool dog-specific KRC format is apparently specially handled, usually with a cool dog to listen to music is not careful to see his lyrics are different, Just as with the daily listening to the difference is that you can highlight the lyrics verbatim.
Reverse-Compile the cool dog Flash Player and discover this KRC decrypted ActionScript code:
Public Function Loadercompletehandler (param1:bytearray): void{
this.newkeybytes = [64, 71, 97, 119, 94, 50, 116, 71, Bayi, Wu,,,, 206, 210, A, the,;
var result:* = param1;
var krcbytes:* = new ByteArray ();
Result.position = 4;
Result.readbytes (krcbytes);
var l:* = krcbytes.length;
var i:int;
while (I < L) {
krcbytes[i] = krcbytes[i] ^ this.newkeybytes[i% this.newkeyBytes.length];
i = (i + 1);
}
try {
krcbytes.uncompress ();
} catch (Error:securityerror) {
errorfun ("Uncompresserror");
return;
}
krcbytes.position = 0;
THIS.MYLYRIC.DATASTR = Krcbytes.readutfbytes (krcbytes.length);
This.successfun ();
return;
}
This code can be quickly converted to PHP parsing code:
$enKey = Array (the 119, the, the, the 116, the, the, the eight, the, the, the 206, the 210, the, the);
$KRC _content = substr ($KRC _content,4);
$len = strlen ($KRC _content);
$KRC _compress = ';
for ($k = 0; $k < $len; $k + +) {
$KRC _compress. = Chr (ord ($KRC _content[$k)) ^ $enKey [$k%]);
}
$KRC _text = gzuncompress ($KRC _compress);
The above $krc_content for KRC lyrics compressed encrypted text content, got the parse KRC plaintext text lyrics $krc_text, and then can easily converted into LRC lyrics, as follows:
function KRC2LRC ($KRC _content, $glue = "n") {$enKey = Array (64, 71, 97, 119, 94, 50, 116,
71, 81, 54, 49, 45, 206, 210, 110, 105);
$KRC _content = substr ($KRC _content,4);
$len = strlen ($KRC _content);
$KRC _compress = ';
for ($k = 0; $k < $len; $k + +) {$KRC _compress. = Chr (ord ($KRC _content[$k)) ^ $enKey [$k% 16]);
} $KRC _text = gzuncompress ($KRC _compress);
Preg_match_all ("/[(ar|ti|offset):(. +)]/", $KRC _text, $matches);
$LRC _text = Implode ($glue, $matches [0]). $glue;
Preg_match_all ("/[(d{0,8}), (d{0,8})] (. +)/", $KRC _text, $matches);
Unset ($KRC _text, $KRC _compress, $KRC _content, $enKey);
if (!empty ($matches [1])) {foreach ($matches [1] as $k => $v) {list ($seconds, $millis) = Explode ('. ', $v/1000); $LRC _time = Date (' i:s ', 1388534400 + $seconds).
substr ($millis, 0,2);
$LRC _cont = preg_replace ("/<d{1,8},d{1,8},d{1,8}>/", "", $matches [3][$k]);
$LRC _text. = "[{$LRC _time}]{$LRC _cont}{$glue}";
} return $LRC _text; }
A simple example is as follows:
$content = file_get_contents (' 1.KRC ');
Echo KRC2LRC ($content, ' <br/> ');