Skip to content

Instantly share code, notes, and snippets.

View xixilive's full-sized avatar
🌴
On vacation

xixilive xixilive

🌴
On vacation
View GitHub Profile
@xixilive
xixilive / StringEncoder.cs
Created May 4, 2012 15:00
Base32 string encoder developing with C#
using System;
using System.Collections.Generic;
using System.Text;
namespace Mickey.Utils
{
/// <summary>
/// 字符串编码/解码
/// </summary>
public static class StringEncoder
{
@xixilive
xixilive / string_util.php
Created May 4, 2012 14:59
php function, Base32 string encoder
<?php
/**
* StringUtil
*
* @author mickey
* @version 1.0
* @package Utility
*/
final class StringUtil
{
@xixilive
xixilive / shorten.rb
Created April 28, 2012 10:40
Base32 string encoder, generate a unique shorten string from a long string, such as a url
require 'digest/md5'
module Shorten
#base32
TABLE = %w(a b c d e f g h i j k l m n o p q r s t u v w x y z 2 3 4 6 7 8)
# short('balabala') => Array
# short('balabala',1) => String, Array[1]
def self.short long_str, index = nil
index = (0..3).to_a.include?(index) ? index : nil
hash_string = Digest::MD5.hexdigest(long_str)