创建imgur图像名称

发布于 2024-12-10 00:44:52 字数 298 浏览 3 评论 0原文

看看 imgur 网站上的标准 URL:

http://i.imgur.com/zx24u.jpg

我想知道他们是如何想出 zx24u 字符串的?

为什么我问:

我使用 MD5 创建图像的十六进制摘要,然后将其存储在数据库中。摘要如下所示:

8da0ed0e5862b120a886a29d7800b59b

我只是想知道应该如何获取 ASCII 和 url 友好的图像名称。 (我是java用户)

Take a look at the standard URL from imgur website:

http://i.imgur.com/zx24u.jpg

I was wondering how do they come up with zx24u string?

Why I'm asking:

I use MD5 to create hex digest of image and than I store it in a database. The digest looks like this:

8da0ed0e5862b120a886a29d7800b59b

I'm just wondering what should I do to get ASCII and url friendly image name. (I'm java user)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的旅程 2024-12-17 00:44:52

您可以使用随机数生成器,以散列作为种子并将其输出范围调整为您的 ASCII 范围。

Random r = new Random(digest);

String str = "";

while (str.length < 5) {
    int i = r.nextInt(128);

    if (i > (int)'a' && i < (int)'z')
        str += (char)i;
}

You can use a random number generator, seeded with the hash and fit the range of its output to your ASCII range.

Random r = new Random(digest);

String str = "";

while (str.length < 5) {
    int i = r.nextInt(128);

    if (i > (int)'a' && i < (int)'z')
        str += (char)i;
}
情绪操控生活 2024-12-17 00:44:52

您可以去掉它的前几个字符,也可以生成一个随机字符串来识别图像。我认为imgur使用第二种方式。

You can strip the first few character for it, or you can generate a random string for identify image. I think imgur uses the second way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文