你在寻找类似的东西Digest吗?
>> require 'Digest'
=> true
>> x = "12th Park Street - Residential"
=> "12th Park Street - Residential"
>> Digest::MD5.hexdigest(x)[0..9]
=> "c68636e164"
>> Digest::SHA1.hexdigest(x)[0..9]
=> "e3d93a448b"
Run Code Online (Sandbox Code Playgroud)
在9个字符应该是相对独特的,但也可以使用完整的摘要.使它更加独特.
>> Digest::SHA1.hexdigest(x)
=> "e3d93a448baa56cc7bdbf896fa32c827350592cc"
>> Digest::MD5.hexdigest(x)
=> "c68636e164b08d037b77d0d5768095d0"
Run Code Online (Sandbox Code Playgroud)