swarmlib/util.py
changeset 268 6ceb8700106f
parent 181ddb2718aa079
       1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
       2 +++ b/swarmlib/util.py	Sun Apr 06 22:56:04 2008 -0400
       3 @@ -0,0 +1,39 @@
       4 +#!/usr/bin/env python
       5 +#
       6 +# data_tools - Various tools to manipulate data
       7 +#
       8 +# Copyright 2007 Sam Hart
       9 +#
      10 +# This program is free software; you can redistribute it and/or modify
      11 +# it under the terms of the GNU General Public License as published by
      12 +# the Free Software Foundation; either version 2 of the License, or
      13 +# (at your option) any later version.
      14 +#
      15 +# This program is distributed in the hope that it will be useful,
      16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
      17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18 +# GNU General Public License for more details.
      19 +#
      20 +# You should have received a copy of the GNU General Public License
      21 +# along with this program; if not, write to the Free Software
      22 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      23 +#
      24 +# Author: Sam Hart
      25 +
      26 +"""
      27 +Swarm utility functions
      28 +
      29 +A collection of utility functions used by Swarm
      30 +"""
      31 +
      32 +import sha
      33 +
      34 +def get_hash(str1, str2, str3):
      35 +    """
      36 +    get_unique_hash(str1, str2, str3):
      37 +    Given three strings, will return a unique hex hash
      38 +    """
      39 +    h = sha.new(str1)
      40 +    h.update(str2)
      41 +    h.update(str3)
      42 +    return h.hexdigest()