<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Cookbook%3AAccessing_CD_Key_Hash</id>
	<title>Cookbook:Accessing CD Key Hash - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=Cookbook%3AAccessing_CD_Key_Hash"/>
	<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Cookbook:Accessing_CD_Key_Hash&amp;action=history"/>
	<updated>2026-08-06T01:09:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://bf2tech.uturista.pt/index.php?title=Cookbook:Accessing_CD_Key_Hash&amp;diff=97&amp;oldid=prev</id>
		<title>Pireax: /* Discussion */</title>
		<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Cookbook:Accessing_CD_Key_Hash&amp;diff=97&amp;oldid=prev"/>
		<updated>2018-06-21T19:34:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Discussion&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:34, 21 June 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l47&quot;&gt;Line 47:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In principle you could do the same sort of thing with the &amp;lt;code&amp;gt;pb_sv_plist&amp;lt;/code&amp;gt; command to retrieve each player&amp;#039;s [[Player_Identity#PunkBuster_GUID|PunkBuster GUID]]. Unfortunately, there is a bug/&amp;quot;unimplemented feature&amp;quot; in BF2, the result of which is that Python and RCon clients never get any output from PunkBuster commands.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;In principle you could do the same sort of thing with the &amp;lt;code&amp;gt;pb_sv_plist&amp;lt;/code&amp;gt; command to retrieve each player&amp;#039;s [[Player_Identity#PunkBuster_GUID|PunkBuster GUID]]. Unfortunately, there is a bug/&amp;quot;unimplemented feature&amp;quot; in BF2, the result of which is that Python and RCon clients never get any output from PunkBuster commands.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you need to convert CD keys into key hashes, check out [[Cookbook:Computing_CD_Key_Hashes|keyHash&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] or [[BF2_Key_Hasher|BF2_Key_Hasher&lt;/del&gt;]].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you need to convert CD keys into key hashes, check out [[Cookbook:Computing_CD_Key_Hashes|keyHash]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==  Submitted By  ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==  Submitted By  ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--Woody&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;--Woody&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pireax</name></author>
	</entry>
	<entry>
		<id>https://bf2tech.uturista.pt/index.php?title=Cookbook:Accessing_CD_Key_Hash&amp;diff=85&amp;oldid=prev</id>
		<title>Pireax: Created page with &quot;==  Problem  ==  You want to access the CD Key Hashes for players in a game from within a Python script.  ==  Solution  ==  Use the &lt;code&gt;host....&quot;</title>
		<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=Cookbook:Accessing_CD_Key_Hash&amp;diff=85&amp;oldid=prev"/>
		<updated>2018-06-21T19:27:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==  Problem  ==  You want to access the &lt;a href=&quot;/index.php/Player_Identity#CD_Key_Hash&quot; title=&quot;Player Identity&quot;&gt;CD Key Hashes&lt;/a&gt; for players in a game from within a Python script.  ==  Solution  ==  Use the &amp;lt;code&amp;gt;host....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Problem  ==&lt;br /&gt;
&lt;br /&gt;
You want to access the [[Player_Identity#CD_Key_Hash|CD Key Hashes]] for players in a game from within a Python script.&lt;br /&gt;
&lt;br /&gt;
==  Solution  ==&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;host.rcon_invoke&amp;lt;/code&amp;gt; method to send the &amp;lt;code&amp;gt;admin.listPlayers&amp;lt;/code&amp;gt; command to the game engine; then use a regular expression to parse the resulting table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  import re&lt;br /&gt;
 &lt;br /&gt;
  def playerData():&lt;br /&gt;
      &amp;#039;&amp;#039;&amp;#039;Returns a dictionary containing player data; dictionary keys are&lt;br /&gt;
         playerIDs, values are 4-element tuples, containing player name,&lt;br /&gt;
         IP address, IP port, and cd-key hash.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
     &lt;br /&gt;
      rawData = host.rcon_invoke(&amp;quot;admin.listplayers&amp;quot;)&lt;br /&gt;
     &lt;br /&gt;
      pattern = re.compile(r&amp;#039;&amp;#039;&amp;#039;^Id:\ +(\d+)                              # PlayerID&lt;br /&gt;
                               \ -\ (\S+)                                # Player Name&lt;br /&gt;
                               \ is\ remote\ ip:\ (\d+\.\d+\.\d+\.\d+):  # IP Address&lt;br /&gt;
                               (\d+)                                     # Port Number&lt;br /&gt;
                               (?:.*hash:\ (\w{32}))?                    # CD Key Hash&lt;br /&gt;
                            &amp;#039;&amp;#039;&amp;#039;, re.DOTALL | re.MULTILINE | re.VERBOSE)&lt;br /&gt;
     &lt;br /&gt;
      result = {}&lt;br /&gt;
      for player in pattern.findall(rawData):&lt;br /&gt;
          result[int(player[0])] = player[1:]&lt;br /&gt;
     &lt;br /&gt;
      return result&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==  Discussion  ==&lt;br /&gt;
&lt;br /&gt;
This function packages the parsed data into a dictionary keyed by [[Player_Identity#Player_ID|Player ID]] for easy access.&lt;br /&gt;
&lt;br /&gt;
A simple example of how you would use this function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # print a list of player names, IP addresses, and CD key hashes:&lt;br /&gt;
 &lt;br /&gt;
 info = playerData()&lt;br /&gt;
 for playerID in info:&lt;br /&gt;
     print info[playerID][0], info[playerID][1], info[playerID][3]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In principle you could do the same sort of thing with the &amp;lt;code&amp;gt;pb_sv_plist&amp;lt;/code&amp;gt; command to retrieve each player&amp;#039;s [[Player_Identity#PunkBuster_GUID|PunkBuster GUID]]. Unfortunately, there is a bug/&amp;quot;unimplemented feature&amp;quot; in BF2, the result of which is that Python and RCon clients never get any output from PunkBuster commands.&lt;br /&gt;
&lt;br /&gt;
If you need to convert CD keys into key hashes, check out [[Cookbook:Computing_CD_Key_Hashes|keyHash]] or [[BF2_Key_Hasher|BF2_Key_Hasher]].&lt;br /&gt;
&lt;br /&gt;
==  Submitted By  ==&lt;br /&gt;
&lt;br /&gt;
--Woody&lt;/div&gt;</summary>
		<author><name>Pireax</name></author>
	</entry>
</feed>