2013-07-19 234 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,但你的紅寶石代碼看起來很複雜。 –