Skip to content

Instantly share code, notes, and snippets.

@klemmchr
Forked from fank/beguidcalc.md
Last active March 9, 2018 17:15
Show Gist options
  • Select an option

  • Save klemmchr/53053b6d6438df9a9718c23c0d6bbd69 to your computer and use it in GitHub Desktop.

Select an option

Save klemmchr/53053b6d6438df9a9718c23c0d6bbd69 to your computer and use it in GitHub Desktop.

Revisions

  1. Christian revised this gist Oct 17, 2016. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions generateGUID.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    -- http://sqlfiddle.com/#!9/6cc709/1

    CREATE FUNCTION `generateGUID`(`playerid` BIGINT UNSIGNED) RETURNS varchar(32) CHARSET latin1
    DETERMINISTIC
    BEGIN
    DECLARE temp text CHARSET ascii;
    DECLARE i int;

    SET i = 0;
    SET temp = "";

    WHILE i < 8 DO
    SET temp = CONCAT(temp, CHAR(playerid & 0xFF));
    SET playerid = playerid >> 8;
    SET i = i + 1;
    END WHILE;

    RETURN MD5(CONCAT("BE", temp));
    END
  2. @fank fank revised this gist Mar 6, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions example.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    -- Microsoft SQL Server
    -- https://github.com/Fankserver/Microsoft-SQL-Server-Assemblies/tree/master/BattlEye
    SELECT SteamIdToBattlEyeGUID(76561197996545192);
  3. @fank fank revised this gist Oct 29, 2014. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion example.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,15 @@
    <?php //Cheers Rommel

    /* Verify that following value is higher than 2147483647(32bit):
    echo PHP_INT_MAX;
    */

    $steamID = '76561197996545192';
    $temp = '';

    for ($i = 0; $i < 8; $i++) {
    $temp .= chr($steamID & 0xFF);
    $steamID = $steamID >> 8;
    $steamID >>= 8;
    }

    $return = md5('BE' . $temp);
  4. @fank fank revised this gist Oct 21, 2014. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions example.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php //Cheers Rommel
    $steamID = '76561197996545192';
    $temp = '';

    for ($i = 0; $i < 8; $i++) {
    $temp .= chr($steamID & 0xFF);
    $steamID = $steamID >> 8;
    }

    $return = md5('BE' . $temp);

    echo $return;
    ?>
  5. @fank fank revised this gist Sep 9, 2014. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    var crypto = require('crypto');
    var int64 = require('int64-native');

    var md5Hash = crypto.createHash('md5');
    var steamId = new int64('76561197996545192'); // The steamid must be a STRING! not a number!

    md5Hash.update('BE');
    for (var i = 0; i < 8; i++) {
    md5Hash.update(String.fromCharCode(steamId.and(0xFF).toNumber()));
    steamId = steamId.shiftRight(8);
    }

    console.log(md5Hash.digest('hex'));
  6. @fank fank revised this gist Aug 13, 2014. 4 changed files with 15 additions and 1 deletion.
    1 change: 1 addition & 0 deletions example.cpp
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,5 @@ for (int i = 0; i < sizeof(parts); i++) {
    bestring << char(parts[i]);
    }

    // I used this md5 library http://www.zedwood.com/article/cpp-md5-function
    std::cout << md5(bestring.str()) << std::endl;
    2 changes: 1 addition & 1 deletion example.cs
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ class Program
    {
    static void Main(string[] args)
    {
    Int64 SteamId = 76561197961199490;
    Int64 SteamId = 76561197996545192;
    byte[] parts = { 0x42, 0x45, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte counter = 2;

    2 changes: 2 additions & 0 deletions example.go
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    // Thanks to nano2k
    package main


    import (
    "crypto/md5"
    "fmt"
    11 changes: 11 additions & 0 deletions example.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # Thanks to gunlinux
    import md5

    steamid=76561197996545192
    temp = ""
    for i in range(8):
    temp += chr((steamid & 0xFF))
    steamid >>= 8
    m = md5.new("BE"+temp)

    print m.hexdigest()
  7. @fank fank revised this gist Jun 29, 2014. 1 changed file with 23 additions and 29 deletions.
    52 changes: 23 additions & 29 deletions example.cs
    Original file line number Diff line number Diff line change
    @@ -7,35 +7,29 @@

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    Int64 SteamId = 76561198040949860;
    sbyte[] parts = { 0, 0, 0, 0, 0, 0, 0, 0 };
    byte counter = 0;
    class Program
    {
    static void Main(string[] args)
    {
    Int64 SteamId = 76561197961199490;
    byte[] parts = { 0x42, 0x45, 0, 0, 0, 0, 0, 0, 0, 0 };
    byte counter = 2;

    do
    {
    parts[counter++] = (sbyte)(SteamId & 0xFF);
    } while ((SteamId >>= 8) > 0);
    do
    {
    parts[counter++] = (byte)(SteamId & 0xFF);
    } while ((SteamId >>= 8) > 0);

    String bestring = "BE";
    for (int i = 0; i < parts.Length; i++)
    {
    bestring = bestring + (char)parts[i];
    }
    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] beHash = md5.ComputeHash(parts);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < beHash.Length; i++)
    {
    sb.Append(beHash[i].ToString("x2"));
    }

    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] textToHash = Encoding.Default.GetBytes(bestring);
    byte[] result = md5.ComputeHash(textToHash);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < result.Length; i++)
    {
    sb.Append(result[i].ToString("x2"));
    }

    Console.Out.WriteLine(sb.ToString());
    }
    }
    }
    Console.Out.WriteLine(sb.ToString());
    Console.In.Read();
    }
    }
    }
  8. @fank fank revised this gist Jun 29, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions example.cs
    Original file line number Diff line number Diff line change
    @@ -12,12 +12,12 @@ class Program
    static void Main(string[] args)
    {
    Int64 SteamId = 76561198040949860;
    Int64[] parts = { 0, 0, 0, 0, 0, 0, 0, 0 };
    sbyte[] parts = { 0, 0, 0, 0, 0, 0, 0, 0 };
    byte counter = 0;

    do
    {
    parts[counter++] = SteamId & 0xFF;
    parts[counter++] = (sbyte)(SteamId & 0xFF);
    } while ((SteamId >>= 8) > 0);

    String bestring = "BE";
  9. @fank fank revised this gist Jun 28, 2014. 1 changed file with 41 additions and 0 deletions.
    41 changes: 41 additions & 0 deletions example.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    {
    Int64 SteamId = 76561198040949860;
    Int64[] parts = { 0, 0, 0, 0, 0, 0, 0, 0 };
    byte counter = 0;

    do
    {
    parts[counter++] = SteamId & 0xFF;
    } while ((SteamId >>= 8) > 0);

    String bestring = "BE";
    for (int i = 0; i < parts.Length; i++)
    {
    bestring = bestring + (char)parts[i];
    }

    MD5 md5 = new MD5CryptoServiceProvider();
    byte[] textToHash = Encoding.Default.GetBytes(bestring);
    byte[] result = md5.ComputeHash(textToHash);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < result.Length; i++)
    {
    sb.Append(result[i].ToString("x2"));
    }

    Console.Out.WriteLine(sb.ToString());
    }
    }
    }
  10. @fank fank revised this gist Apr 20, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion beguidcalc.md
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    # md5("BE" (2 bytes) + 64-bit SteamID (8 bytes))
    ## md5("BE" (2 bytes) + 64-bit SteamID (8 bytes))
  11. @fank fank created this gist Apr 20, 2014.
    1 change: 1 addition & 0 deletions beguidcalc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # md5("BE" (2 bytes) + 64-bit SteamID (8 bytes))
    12 changes: 12 additions & 0 deletions example.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    std::stringstream bestring;
    __int64 steamID = 76561197996545192;
    __int8 i = 0, parts[8] = { 0 };
    do parts[i++] = steamID & 0xFF;
    while (steamID >>= 8);

    bestring << "BE";
    for (int i = 0; i < sizeof(parts); i++) {
    bestring << char(parts[i]);
    }

    std::cout << md5(bestring.str()) << std::endl;
    20 changes: 20 additions & 0 deletions example.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    package main

    import (
    "crypto/md5"
    "fmt"
    )

    func main() {
    steamid := 76561197996545192

    h := md5.New()
    h.Write([]byte("BE"))

    for i := 0; i < 8; i++ {
    h.Write([]byte{byte(steamid & 0xFF)})
    steamid >>= 8
    }

    fmt.Printf("Battleye GUID: %x", h.Sum(nil))
    }