Fixed DepotDownloader for the latest SteamKit2 version.

pull/8/head
Ryan Stecker 14 years ago
parent eb483d207f
commit a17713e153

@ -5,6 +5,8 @@ using System.Text;
using System.IO;
using SteamKit2;
using System.Net;
using System.Security.Cryptography;
using SteamKit2.Blob;
namespace DepotDownloader
{
@ -190,7 +192,7 @@ namespace DepotDownloader
if ( ver.VersionID == version )
{
if ( ver.IsEncryptionKeyAvailable )
return Utils.DecodeHexString( ver.DepotEncryptionKey );
return DecodeHexString( ver.DepotEncryptionKey );
break;
}
}
@ -198,6 +200,20 @@ namespace DepotDownloader
return null;
}
static byte[] DecodeHexString( string hex )
{
if ( hex == null )
return null;
int chars = hex.Length;
byte[] bytes = new byte[ chars / 2 ];
for ( int i = 0 ; i < chars ; i += 2 )
bytes[ i / 2 ] = Convert.ToByte( hex.Substring( i, 2 ), 16 );
return bytes;
}
public static List<int> GetDepotIDsForApp( int appId, bool allPlatforms )
{
List<int> depotIDs = new List<int>();
@ -403,12 +419,22 @@ namespace DepotDownloader
if ( cdr == null )
return null;
return CryptoHelper.SHAHash( cdr );
return SHAHash( cdr );
}
catch
{
return null;
}
}
static byte[] SHAHash( byte[] data )
{
using ( SHA1Managed sha = new SHA1Managed() )
{
byte[] output = sha.ComputeHash( data );
return output;
}
}
}
}

@ -561,7 +561,7 @@ namespace DepotDownloader
foreach (var chunk in file.Chunks)
{
string chunkID = Utils.EncodeHexString(chunk.ChunkID);
string chunkID = EncodeHexString(chunk.ChunkID);
byte[] encrypted_chunk = cdnClient.DownloadDepotChunk(depotId, chunkID);
byte[] chunk_data = cdnClient.ProcessChunk(encrypted_chunk, depotKey);
@ -749,5 +749,12 @@ namespace DepotDownloader
return null;
}
static string EncodeHexString( byte[] input )
{
return input.Aggregate( new StringBuilder(),
( sb, v ) => sb.Append( v.ToString( "x2" ) )
).ToString();
}
}
}

@ -5,6 +5,7 @@ using System.Text;
using SteamKit2;
using System.IO;
using System.Text.RegularExpressions;
using SteamKit2.Blob;
namespace DepotDownloader
{

Loading…
Cancel
Save