2013-07-19 138 views

回答

3

如果你有postId,有一种方法可以按照他们的方式对它进行散列。

vine_key = 'BuzaW7ZmKAqbhMOei5J1nvr6gXHwdpDjITtFUPxQ20E9VY3Ll' 
example_post_id = 910326069930893312 

change example_post_id to base-49 (its vine_key size) 
# => [11, 20, 1, 14, 10, 7, 44, 12, 42, 4, 11] 
replace each digit of the base-49 number with the corresponding character on the vine_key # 0: B, 1: u, 2:z ... 47: L, 48: l 
# => [b, n, u, O, q, m, V, h, E, W, b] 
BOOM, you've got the hashed id 
# => "bnuOqmVhEWb" 

我实现了它的红宝石,如果你有兴趣:https://gist.github.com/davoclavo/7460039

+0

@davoclavo你好:有没有办法在Java中实现这种方法吗?我尝试去散列哈希ID来获得后ID,但你的红宝石代码看起来很复杂。 –