forked from ppy/osu-stream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasher.cs
More file actions
48 lines (40 loc) · 1.49 KB
/
Hasher.cs
File metadata and controls
48 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
namespace StreamFormatDecryptor
{
public class Hasher{
public const bool UseLegacyOsz2Key = false;
public const bool UseOsf2KeyForOsz2 = false;
public static byte[] CreateMD5(byte[] input)
{
// Use input string to calculate MD5 hash
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
{
byte[] hashBytes = md5.ComputeHash(input);
return hashBytes;
}
}
public byte[] AESDecryptKey(string ArtistName, string BeatmapSetID, string Mapper, string SongTitle, bool is_osz2){
string KeyAlg = "";
if (is_osz2 && !UseOsf2KeyForOsz2)
{
KeyAlg = (UseLegacyOsz2Key ? (char)0x08 : string.Empty) + Mapper + "yhxyfjo5" + BeatmapSetID;
Console.WriteLine($"Using key seed from osz2: '{KeyAlg}' (Length: {KeyAlg.Length})");
Console.WriteLine($"Seed hex: {Convert.ToHexString(Encoding.UTF8.GetBytes(KeyAlg))}");
}
else
{
KeyAlg = (char)0x08 + SongTitle + "4390gn8931i" + ArtistName;
Console.WriteLine($"Using key seed from osf2/mixed: '{KeyAlg}' (Length: {KeyAlg.Length})");
Console.WriteLine($"Seed hex: {Convert.ToHexString(Encoding.UTF8.GetBytes(KeyAlg))}");
}
byte[] Key = CreateMD5(Encoding.ASCII.GetBytes(KeyAlg))!;
return Key;
}
}
}