


Recently, when I was collecting lyrics from Kugou Music, I found that the lyrics of Kugou Music were all "garbled" when I browsed them directly. The lyrics I usually see are all text in lrc format. This kind of krc format is dedicated to Kugou. It has obviously been specially processed. I usually listen to music with Kugou and I don’t look carefully at the differences in the lyrics. However, unlike Tiantianjingting, etc., the lyrics can be highlighted word by word.
Decompile Kugou’s flash player and find this krc-decrypted ActionScript code:
public function loaderCompleteHandler(param1:ByteArray) : void{ this.newkeyBytes = [64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105]; 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; }
According to this code, it can be quickly converted into PHP parsing code:
$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);
The above $krc_content is the compressed and encrypted text content of krc lyrics. The parsed krc plain text lyrics $krc_text is obtained, and then it can be 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/>');

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!
