def generate_random_id(method)
      data = File.open("/dev/urandom", "rb") do |f|
        f.read(64)
      end
      case method
      when :base64
        data = base64(data)
        data.gsub!("+", '')
        data.gsub!("/", '')
        data.gsub!(/==$/, '')
        return data
      when :hex
        return data.unpack('H*')[0]
      else
        raise ArgumentError, "Invalid method #{method.inspect}"
      end
    end
def generate_random_id(method)
      data = File.open("/dev/urandom", "rb") do |f|
        f.read(64)
      end
      case method
      when :base64
        data = base64(data)
        data.gsub!("+", '')
        data.gsub!("/", '')
        data.gsub!(/==$/, '')
        return data
      when :hex
        return data.unpack('H*')[0]
      else
        raise ArgumentError, "Invalid method #{method.inspect}"
      end
    end
Generate a long, cryptographically secure random ID string, which
 is also a valid filename.