Re: [google-appengine] Hash function

2015-05-27 Thread Jeff Schnitzer
Alternatively, just use the id generator. Personally I use the id generator
and crockford's base32 encoding variant to generate "pretty" (that is,
short enough to type or read over phone if necessary) ids for public URLs.

Jeff

On Wed, May 27, 2015 at 7:55 AM, Karl MacMillan  wrote:

>
>  On May 27, 2015, at 10:50 AM, Saturnino Mateus 
> wrote:
>
> Hello! I need to create a page to tracking orders, each order must have a
> key. How can i generate this key? Im thinking use hash, is there any good
> hash function without colision? Is there other way to solve it with GAE?
>
>
> This isn’t exactly GAE specific, but you probably want a UUID:
>
> https://docs.oracle.com/javase/7/docs/api/java/util/UUID.html
>  https://docs.python.org/2/library/uuid.html
>
> Karl
>
>  Regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-appengine.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/e4ed5136-9aae-47b2-a34c-5635526a541f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>
>   --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-appengine.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/E6774E7B-84AF-46F0-AF2B-7BC6B43E7633%40rakkoon.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CADK-0ujxkGZzptcxqKKYXTtAvfSH3FNmLUdR_Xmr_zvMk51EAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [google-appengine] Hash function

2015-05-27 Thread Karl MacMillan
  

> On May 27, 2015, at 10:50 AM, Saturnino Mateus  wrote:
> 
> 
> Hello! I need to create a page to tracking orders, each order must have a 
> key. How can i generate this key? Im thinking use hash, is there any good 
> hash function without colision? Is there other way to solve it with GAE?
> 
> 
> 

This isn’t exactly GAE specific, but you probably want a UUID:


https://docs.oracle.com/javase/7/docs/api/java/util/UUID.html

https://docs.python.org/2/library/uuid.html



Karl


> Regards
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-appengine.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/google-appengine/e4ed5136-9aae-47b2-a34c-5635526a541f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/E6774E7B-84AF-46F0-AF2B-7BC6B43E7633%40rakkoon.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Hash function

2015-05-27 Thread Saturnino Mateus
Hello! I need to create a page to tracking orders, each order must have a key. 
How can i generate this key? Im thinking use hash, is there any good hash 
function without colision? Is there other way to solve it with GAE?

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/e4ed5136-9aae-47b2-a34c-5635526a541f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[google-appengine] Hash function: migrating from Python 2.5 to Python 2.7

2012-02-20 Thread Andrin von Rechenberg
The built-in hash function differs from Python2.5 to Python2.7.

If you are planning to migrate from Python 2.5 to Python 2.7 and
you were dumb enough to store the value of python 2.5's hash
function, just like I did, you might be interested in the following
code snippet.

This is the hash function that Google uses in production for python 2.5:

def c_mul(a, b):

  return eval(hex((long(a) * b) & 0xL)[:-1])

def py25hash(self):

  if not self:

return 0 # empty

  value = ord(self[0]) << 7

  for char in self:

value = c_mul(103, value) ^ ord(char)

  value = value ^ len(self)

  if value == -1:

value = -2

  return value


I wonder why Google is not using 64bit hashes in Python 2.7

Cheers,
-Andrin

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.