base62

convert base64 to base62 (without special characters)

久未见 提交于 2020-12-30 02:42:07
问题 I want to pass a blowfish encrypted string in a URL, and want to encode it like base64, but without any special character, something like base62 would be great (0-9a-zA-Z). So what I'm trying to do is converting the blowfish encrypted string using base64_encode, and convert base64 to base62. I know about solutions how to make base64 url-safe, but I really don't want any special character in the string. convert_base() only works with base up to 36, the math extensions can convert up to base 62

Obfuscating ids in Rails app

岁酱吖の 提交于 2020-01-05 04:14:24
问题 I'm trying to obfuscate all the ids that leave the server, i.e., ids appearing in URLs and in the HTML output. I've written a simple Base62 lib that has the methods encode and decode. Defining—or better—overwriting the id method of an ActiveRecord to return the encoded version of the id and adjusting the controller to load the resource with the decoded params[:id] gives me the desired result. The ids now are base62 encoded in the urls and the response displays the correct resource. Now I

Convert a string into BASE62

僤鯓⒐⒋嵵緔 提交于 2019-12-21 05:18:07
问题 I'm looking for the c# code to convert a string into BASE62, like this: http://www.molengo.com/base62/title/base62-encoder-decoder I need those encode and decode-methods for URL-Encoding. 回答1: Try the C# library available here which adds some extension methods to allow you to convert a byte array to and from BASE62. https://github.com/renmengye/base62-csharp If your source data is contained in a "string" then you would first need to convert your "string" to a suitable byte array. But be

Multi-base conversion - using all combinations for URL shortener

不打扰是莪最后的温柔 提交于 2019-12-19 11:36:12
问题 I am making an URL shortener, and I am struggling with the optimal way of encoding a number (id) into a character string. I am using the characters 0-9,A-Z,a-z so it will basically be a base-62 encoding. That is pretty basic, but it doesn't make use of all possible codes. The codes that it would produce would be: 0, 1, ... y, z, 10, 11, ... zy, zz, 100, 101, ... Notice that the codes 00 to 0z is not used, the same for 000 to 0zz, and so on. I would like to use all the codes, like this: 0, 1,

Base 62 conversion

回眸只為那壹抹淺笑 提交于 2019-12-17 02:02:30
问题 How would you convert an integer to base 62 (like hexadecimal, but with these digits: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'). I have been trying to find a good Python library for it, but they all seems to be occupied with converting strings. The Python base64 module only accepts strings and turns a single digit into four characters. I was looking for something akin to what URL shorteners use. 回答1: There is no standard module for this, but I have written my own

PHP - How to base_convert() up to base 62

好久不见. 提交于 2019-12-12 07:12:29
问题 I need a base_convert() function that works from base 2 up to base 62 but I'm missing the math I need to use, I know that due to the limitations of PHP I need to make use of bcmath, which is fine. Functions like these convert a number to and from base 10 to another base up to 62, but I want to implement the same functionality of base_convert() , e.g.: a only one function that can convert between arbitrary bases. I've found a function that seems to do this, but it gives me the feeling of

Convert MD5 to base62 for URL

早过忘川 提交于 2019-11-30 13:22:01
问题 I have a script to convert to base 62 (A-Za-z0-9) but how do I get a number out of MD5? I have read in many places that because the number from an MD5 is bigger than php can handle as an integer it will be inaccurate... As I want a short URL anyway and was not planning on using the whole hash, maybe just 8 characters of it.... So my question is how to get part of the number of an MD5 hash? Also is it a bad idea to use only part of the MD5 hash? 回答1: I'm going to suggest a different thing here

Convert MD5 to base62 for URL

点点圈 提交于 2019-11-30 09:53:23
I have a script to convert to base 62 (A-Za-z0-9) but how do I get a number out of MD5? I have read in many places that because the number from an MD5 is bigger than php can handle as an integer it will be inaccurate... As I want a short URL anyway and was not planning on using the whole hash, maybe just 8 characters of it.... So my question is how to get part of the number of an MD5 hash? Also is it a bad idea to use only part of the MD5 hash? I'm going to suggest a different thing here.. Since you are only interested in using a decimal chunk of the md5 hash why don't you use any other short