test.bat- #&cls&@cd /d "%~dp0" & powershell -c "$cur_dir='%~dp0';Get-Content '%~0' | Out-String | Invoke-Expression" &pause&exit
- $file = '胡歌 - 逍遥叹.krc'
- #密钥
- $key = @(64, 71, 97, 119, 94, 50, 116, 71, 81, 54, 49, 45, 206, 210, 110, 105)
- #加载dll
- [void][System.Reflection.Assembly]::LoadFile($cur_dir+'zlib.dll')
- #读取源文件
- $bytes = [System.IO.File]::ReadAllBytes($file)
- #解密
- $compress_bytes = New-Object 'System.Collections.ArrayList'
- for($i = 4; $i -lt $bytes.Count-4; $i++){ [void]$compress_bytes.Add(($bytes[$i] -bxor $key[($i-4)%16])) }
- #解压缩
- $str = [Ionic.Zlib.ZlibStream]::UncompressString($compress_bytes)
- #转lrc
- &{
- $str -split '\r\n' | foreach {
- if($_ -match '^\[(\d+),(\d+)\]'){
- $t = (New-Object 'datetime' (([int]$Matches[1])*10000)).ToString('[mm:ss.ff]')
- $s = $_ -replace '\[\d+?,\d+\]','' -replace '<\d+?,\d+?,\d+>',''
- $t + $s
- }
- }
- } | Out-File ($file -replace 'krc$','lrc')
复制代码 需要zlib库,和bat放一起zlib.dll |