Convert Figma logo to code with AI

schollz logocroc

Easily and securely send things from one computer to another :crocodile: :package:

27,614
1,098
27,614
10

Top Related Projects

get things from one computer to another, safely

🚀 Streaming file transfer over WebTorrent (torrents on the web)

16,006

An IPFS implementation in Go

63,682

Open Source Continuous File Synchronization

A Smart Ethernet Switch for Earth

Quick Overview

Croc is a tool for securely transferring files between computers. It allows for easy and fast file sharing through relay-assisted peer-to-peer connections, with end-to-end encryption and no size limits.

Pros

  • Simple and user-friendly command-line interface
  • End-to-end encryption for secure file transfers
  • No file size limits or account registration required
  • Cross-platform support (Windows, macOS, Linux)

Cons

  • Requires both sender and receiver to have croc installed
  • May be slower than direct file transfer methods for local network transfers
  • Limited customization options compared to some other file transfer tools
  • Relies on public relay servers by default (though self-hosting is possible)

Getting Started

  1. Install croc:
curl https://getcroc.schollz.com | bash
  1. Send a file:
croc send /path/to/file
  1. Receive a file (on another computer):
croc [code-phrase]

Replace [code-phrase] with the code provided by the sender.

Competitor Comparisons

get things from one computer to another, safely

Pros of magic-wormhole

  • Provides end-to-end encryption for secure file transfer
  • Supports transferring multiple files and directories
  • Has a well-documented protocol and API for integration

Cons of magic-wormhole

  • Requires Python installation, which may not be available on all systems
  • Can be more complex to set up and use for non-technical users
  • Limited built-in resume functionality for interrupted transfers

Code Comparison

magic-wormhole:

from wormhole.cli.public_relay import RENDEZVOUS_RELAY
from wormhole.cli.cli import go
go(RENDEZVOUS_RELAY)

croc:

package main

import "github.com/schollz/croc/v9/src/cli"

func main() {
    cli.Run()
}

Both projects aim to provide secure file transfer capabilities, but they differ in implementation and features. magic-wormhole offers a more comprehensive protocol with broader file transfer options, while croc focuses on simplicity and ease of use. The code comparison shows that magic-wormhole is implemented in Python, whereas croc is written in Go, which may impact performance and system compatibility.

🚀 Streaming file transfer over WebTorrent (torrents on the web)

Pros of instant.io

  • Browser-based file sharing without installation
  • Supports streaming of media files
  • Utilizes WebTorrent for efficient peer-to-peer transfers

Cons of instant.io

  • Requires an active internet connection
  • May have slower transfer speeds for large files
  • Limited control over file encryption and security

Code Comparison

instant.io (JavaScript):

client.seed(file, function (torrent) {
  console.log('Client is seeding:', torrent.infoHash)
})

croc (Go):

c := croc.New(options)
err := c.Send(file)
if err != nil {
    log.Fatal(err)
}

Key Differences

  1. Technology: instant.io uses WebTorrent for peer-to-peer transfers, while croc uses its own protocol.
  2. Platform: instant.io is web-based, croc is a command-line tool.
  3. Encryption: croc focuses on secure, encrypted transfers, while instant.io prioritizes ease of use and streaming capabilities.
  4. File size handling: croc is optimized for large file transfers, instant.io may struggle with very large files.
  5. Offline usage: croc can work offline in local networks, instant.io requires an internet connection.

Both tools serve the purpose of file sharing but cater to different use cases and user preferences.

16,006

An IPFS implementation in Go

Pros of kubo

  • Decentralized and distributed file system, enabling global content-addressed storage
  • Supports a wide range of use cases beyond file transfer, including decentralized websites and applications
  • Offers built-in versioning and content integrity verification

Cons of kubo

  • More complex setup and usage compared to croc's simplicity
  • Requires running a node, which can be resource-intensive for casual users
  • May have slower transfer speeds for direct file sharing between two parties

Code comparison

croc:

# Sending a file
croc send file.txt

# Receiving a file
croc 1234-unique-code

kubo:

# Adding a file to IPFS
ipfs add file.txt

# Retrieving a file from IPFS
ipfs get QmHash

Summary

croc is a simple, direct file transfer tool designed for ease of use and quick peer-to-peer file sharing. It excels in simplicity and speed for direct transfers between two parties.

kubo (IPFS) is a more comprehensive distributed file system that offers a wide range of features beyond simple file transfer. It provides a global, content-addressed network for storing and sharing data, making it suitable for various decentralized applications and use cases.

Choose croc for quick and easy file transfers between two parties, and kubo (IPFS) for more complex, distributed file storage and sharing needs in decentralized environments.

63,682

Open Source Continuous File Synchronization

Pros of Syncthing

  • Continuous file synchronization across multiple devices
  • Decentralized architecture with no central server
  • Supports selective sync and versioning of files

Cons of Syncthing

  • More complex setup and configuration
  • Higher resource usage for continuous syncing
  • Requires devices to be online simultaneously for sync

Code Comparison

Syncthing (Go):

func (m *Model) Index(folder string, fs fs.Filesystem, sub string) error {
    m.fmut.RLock()
    cfg := m.folderCfgs[folder]
    m.fmut.RUnlock()

    if cfg.Type == config.FolderTypeReceiveOnly {
        return errors.New("folder is receive-only")
    }
    // ... (additional code)
}

Croc (Go):

func receive(c *websocket.Conn, codephrase string, isLocal bool, done chan struct{}) {
    // initialize receive
    rs := receiveSession{
        conn:       c,
        isLocal:    isLocal,
        codephrase: codephrase,
    }
    // ... (additional code)
}

While both projects are written in Go, Syncthing focuses on continuous synchronization across multiple devices, whereas Croc is designed for simple, one-time file transfers between two points. Syncthing's code reflects its more complex architecture, while Croc's code is more straightforward, aligning with its simpler use case.

A Smart Ethernet Switch for Earth

Pros of ZeroTierOne

  • Creates a secure, encrypted virtual network for multiple devices
  • Offers more comprehensive networking capabilities, including routing and bridging
  • Supports a wider range of platforms and operating systems

Cons of ZeroTierOne

  • More complex setup and configuration process
  • Requires ongoing management and maintenance of the network
  • Higher resource usage due to its comprehensive networking features

Code Comparison

ZeroTierOne (C++):

void Node::processVirtualNetworkFrame(
    uint64_t now,
    const SharedPtr<Network> &network,
    const MAC &from,
    const MAC &to,
    unsigned int etherType,
    const void *data,
    unsigned int len)

Croc (Go):

func (c *Croc) Send(fname string, codephrase string) (err error) {
    c.ImSender = true
    c.Codephrase = codephrase
    c.FileInfo, err = getFileInfo(fname)
    if err != nil {
        return
    }

Summary

ZeroTierOne is a comprehensive virtual networking solution, offering advanced features for creating secure, encrypted networks across multiple devices and platforms. It provides more extensive networking capabilities but requires more setup and ongoing management.

Croc, on the other hand, is a simpler tool focused on secure file transfer between devices. It offers a more straightforward setup process and is lighter on resources, but lacks the advanced networking features of ZeroTierOne.

The choice between the two depends on the specific use case: ZeroTierOne for complex networking needs, and Croc for quick and easy file transfers.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

croc
Version Build
Status

This project is supported by Github sponsors.

croc is a tool that allows any two computers to simply and securely transfer files and folders. AFAIK, croc is the only CLI file-transfer tool that does all of the following:

  • allows any two computers to transfer data (using a relay)
  • provides end-to-end encryption (using PAKE)
  • enables easy cross-platform transfers (Windows, Linux, Mac)
  • allows multiple file transfers
  • allows resuming transfers that are interrupted
  • local server or port-forwarding not needed
  • ipv6-first with ipv4 fallback
  • can use proxy, like tor

For more information about croc, see my blog post or read a recent interview I did.

Example

Install

Download the latest release for your system, or install a release from the command-line:

curl https://getcroc.schollz.com | bash

On macOS you can install the latest release with Homebrew:

brew install croc

On macOS you can also install the latest release with MacPorts:

sudo port selfupdate
sudo port install croc

On Windows you can install the latest release with Scoop, Chocolatey, or Winget:

scoop install croc
choco install croc
winget install schollz.croc

On Unix you can install the latest release with Nix:

nix-env -i croc

On Alpine Linux you have to install dependencies first:

apk add bash coreutils
wget -qO- https://getcroc.schollz.com | bash

On Arch Linux you can install the latest release with pacman:

pacman -S croc

On Fedora you can install with dnf:

dnf install croc

On Gentoo you can install with portage:

emerge net-misc/croc

On Termux you can install with pkg:

pkg install croc

On FreeBSD you can install with pkg:

pkg install croc

Or, you can install Go and build from source (requires Go 1.17+):

go install github.com/schollz/croc/v10@latest

On Android there is a 3rd party F-Droid app available to download.

Usage

To send a file, simply do:

$ croc send [file(s)-or-folder]
Sending 'file-or-folder' (X MB)
Code is: code-phrase

Then to receive the file (or folder) on another computer, you can just do

croc code-phrase

The code phrase is used to establish password-authenticated key agreement (PAKE) which generates a secret key for the sender and recipient to use for end-to-end encryption.

There are a number of configurable options (see --help). A set of options (like custom relay, ports, and code phrase) can be set using --remember.

Using croc on Linux or Mac OS

On Linux and Mac OS, the sending & receiving is slightly different to avoid leaking the secret via the process name. On these systems you will need to run croc with the secret as an environment variable. For example, to receive with the secret ***:

CROC_SECRET=*** croc

This will show only croc in the process list of a multi-user system and not leak the secret.

For a single-user system the default behavior can be permanently enabled by running

croc --classic

and confirming. Run this command again to disable classic mode.

Custom code phrase

You can send with your own code phrase (must be more than 6 characters).

croc send --code [code-phrase] [file(s)-or-folder]

Allow overwriting without prompt

By default, croc will prompt whether to overwrite a file. You can automatically overwrite files by using the --overwrite flag (recipient only). For example, receive a file to automatically overwrite:

croc --yes --overwrite <code>

Use pipes - stdin and stdout

You can pipe to croc:

cat [filename] | croc send

In this case croc will automatically use the stdin data and send and assign a filename like "croc-stdin-123456789". To receive to stdout at you can always just use the --yes will automatically approve the transfer and pipe it out to stdout.

croc --yes [code-phrase] > out

All of the other text printed to the console is going to stderr so it will not interfere with the message going to stdout.

Send text

Sometimes you want to send URLs or short text. In addition to piping, you can easily send text with croc:

croc send --text "hello world"

This will automatically tell the receiver to use stdout when they receive the text so it will be displayed.

Use a proxy

You can use a proxy as your connection to the relay by adding a proxy address with --socks5. For example, you can send via a tor relay:

croc --socks5 "127.0.0.1:9050" send SOMEFILE

Change encryption curve

You can choose from several different elliptic curves to use for encryption by using the --curve flag. Only the recipient can choose the curve. For example, receive a file using the P-521 curve:

croc --curve p521 <codephrase>

Available curves are P-256, P-348, P-521 and SIEC. P-256 is the default curve.

Change hash algorithm

You can choose from several different hash algorithms. The default is the xxhash algorithm which is fast and thorough. If you want to optimize for speed you can use the imohash algorithm which is even faster, but since it samples files (versus reading the whole file) it can mistakenly determine that a file is the same on the two computers transferring - though this is only a problem if you are syncing files versus sending a new file to a computer.

croc send --hash imohash SOMEFILE

Self-host relay

The relay is needed to staple the parallel incoming and outgoing connections. By default, croc uses a public relay but you can also run your own relay:

croc relay

By default it uses TCP ports 9009-9013. Make sure to open those up. You can customize the ports (e.g. croc relay --ports 1111,1112), but you must have a minimum of 2 ports for the relay. The first port is for communication and the subsequent ports are used for the multiplexed data transfer.

You can send files using your relay by entering --relay to change the relay that you are using if you want to custom host your own.

croc --relay "myrelay.example.com:9009" send [filename]

Note, when sending, you only need to include the first port (the communication port). The subsequent ports for data transfer will be transmitted back to the user from the relay.

Self-host relay (docker)

If it's easier you can also run a relay with Docker:

docker run -d -p 9009-9013:9009-9013 -e CROC_PASS='YOURPASSWORD' schollz/croc

Be sure to include the password for the relay otherwise any requests will be rejected.

croc --pass YOURPASSWORD --relay "myreal.example.com:9009" send [filename]

Note: when including --pass YOURPASSWORD you can instead pass a file with the password, e.g. --pass FILEWITHPASSWORD.

License

MIT

Acknowledgements

croc has gone through many iterations, and I am awed by all the great contributions! If you feel like contributing, in any way, by all means you can send an Issue, a PR, or ask a question.

Thanks @warner for the idea, @tscholl2 for the encryption gists, @skorokithakis for code on proxying two connections. Finally thanks for making pull requests @maximbaz, @meyermarcel, @Girbons, @techtide, @heymatthew, @Lunsford94, @lummie, @jesuiscamille, @threefjord, @marcossegovia, @csleong98, @afotescu, @callmefever, @El-JojA, @anatolyyyyyy, @goggle, @smileboywtu, @nicolashardy, @fbartels, @rkuprov, @hreese, @xenrox and Ipar!