<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_kg(self, kg):
 """Sets the Kg for the BMC to use In RAKP, Kg is a BMC-specific integrity key that can be set. If not set, Kuid is used for the integrity key """

        try:
            self.kg = kg.encode('utf-8')
        except AttributeError:
            self.kg = kg