• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Objective-C
  • Created about 12 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, general, human-sympathetic binary data format

Lich 0.1

Lich is a data format that is:

  • Simple: Lich only has three element types: data, arrays and dictionaries. Each element follows the same syntax (size, open marker, content, close marker).

  • General: Lich's arrays and dictionaries are Just Enough to support self-describing data and general structure inspection and editing tools.

  • Human-sympathetic: Lich is mostly directly readable by humans in hex/ASCII data dumps and even text editors. Lich's markers were chosen to easily allow humans to discover the beginning and ending of elements. The brackets and braces are immediately familiar to anyone with HTML/XML and JSON experience.

  • Binary: Binary data such as images and public keys are directly represented sans any need for encoding or escaping and their associated code-complexity and size-bloat. Lich is a compact format designed for space-constrained environments such as UDP packets.

Lich isn't for everyone since it's:

  • Untyped: Data is directly represented in binary format. No direct attempt is made to provide hints to the reader what the data describes. That said, ASCII can be directly displayed in the Lich stream and dictionary keys often provide enough context to puzzle out a blob's meaning.

  • Tedious to Write by Hand: Lich's size-first format enables its security and efficiency, but it's tedious for humans to count lengths and keep them consistent. Updating a deeply-nested element in a text editor is the worst thing about Lich.

  • Terse: Lich disallows whitespace, making human visual parsing more difficult.

  • Rare: Lich is the new kid on the block, targeting a specific niche. JSON can do everything Liche can do with better tool & API support and human readability/editability, albeit in far more space+time.

Examples

Here's "hello world" in ASCII:

11<hello world>

Lich happily supports UTF-8, but writing Lich streams by hand in a text editor is problematic with non-ASCII strings since UTF-8 is multi-byte (making it easy to get the lengths wrong). So we'll stick with ASCII here.

Here's a dictionary with the same string under a key of "greeting":

26{8<greeting>11<hello world>}

Here's what the same data would look like in JSON:

{"greeting": "hello world"}

JSON wins the beauty contest, but Lich can efficiently host binary data (you probably have to resort to Base64 to do that in JSON).

Here's an array of fruits:

26[5<apple>6<banana>6<orange>]

Same thing in JSON:

["apple", "banana", "orange"]

And of course you can nest structures:

126{14<selling points>40[6<simple>7<general>17<human-sympathetic>]8<greeting>11<hello world>5<fruit>26[5<apple>6<banana>6<orange>]}

And in JSON:

{
	"selling points": ["simple", "general", "human-sympathetic"],
	"greeting": "hello world",
	"fruit: ["apple", "banana", "orange"]
}

Grammar

Here's a pseudo-BNF grammar for Lich:

document            ::=  elements*
element             ::=  data_element | array_element | dictionary_element
data_element        ::=  size '<' byte* '>'
array_element       ::=  size '[' element* ']'
dictionary_element  ::=  size '{' key_value* '}'
key_value           ::=  data_element element
size                ::=  [0-9]{1,20} # Note: must fit into an uint64_t (<= 18,446,744,073,709,551,615 (2^64-1))

Implementation Notes

Lich should be able to be implemented in any practical language. Contributions welcome.

LichCocoa (in the cocoa/ directory) is an implementation of Lich in Objective-C for Cocoa. It should work on both Mac and iOS. It can encode and decode NSData, NSArray and NSDictionaries to Lich and back.

Expected-valid and expected-invalid encoding and decoding examples reside in loch-tests.json. Run rake in Lich's project directory to build TestLichCocoa (a helper tool) and run through the test examples.

Canonical Format

Lich is a straight-forward data format with little leeway, but if you need to generate a canonical stream for crypto purposes, there's two additional generation rules:

  1. Dictionary key-value pairs are sorted data-wise by their key.
  2. Sizes have leading zeros suppressed (issue 4).

The LichCocoa implementation automatically does this for you when generating Lich streams (but doesn't enforce dictionary key ordering when parsing).

Endianess

Because Lich encodes sizes in ASCII digits, its format is endian neutral (data element content bytes can be in little-endian or big-endian format). That said, Lich strongly recommends storing data in network order (big endian).

The Name

I didn't know what to name a new data format, so I had my password generating application show me random words. Lich was the third word. I hadn't heard of it before, but I liked that it was short.

I looked up the definition (a type of undead creature) and thought it fit well with the idea of a serialization format -- "live" objects are serialized to it, reanimating in another process in another time.

How ghoulishly poetic.

Inspirations

See Also

Version History

v0.1: Thu Oct 04 2012

  • Initial Announcement.

More Repositories

1

mogenerator

Core Data code generation
Objective-C
3,029
star
2

jrswizzle

one-stop-shop for all your method swizzling needs
Objective-C
2,659
star
3

mach_inject

interprocess code injection for Mac OS X
C
810
star
4

clicktoflash

WebKit plug-in to prevent automatic loading of Adobe Flash content
Objective-C
714
star
5

markdownlive

Purpose-built Markdown Editor for Mac OS X with Live Preview
C
496
star
6

mach_override

runtime function overriding for Mac OS X
C
427
star
7

AutoLayoutShorthand

alternative system for creating and adding Cocoa Auto Layout constraints
Objective-C
355
star
8

mach_star

code injection and function overriding for Mac OS X
C
254
star
9

JREnum

macros that automate vending an NSString given an enum value (f.x. MyEnumToString(value))
Objective-C
153
star
10

jrfeedbackprovider

nonviral cocoa source for implementing an application feedback panel (for bugs, feature requests and support)
Objective-C
114
star
11

OAuthConsumer

fork of http://code.google.com/p/oauth/ 's Obj-C 2 API
Objective-C
82
star
12

JRTranscriptView

Purpose-built text view for logging output. iOS 7+
Objective-C
67
star
13

stressdrive

tool to completely fill a drive with random data and ensure it can be entirely correctly read back
C
60
star
14

NSInvocation-blocks

Even-easier NSInvocation creation thanks to blocks
Objective-C
54
star
15

JRErr

light at the end of the NSError** tunnel
Objective-C
51
star
16

SafariSessionSaver

Simple app that archives (and restores) Safari's currently-open windows+tabs
Objective-C
50
star
17

MagicHat

Objective-C Binary Documentation Tool. Think classdump with a hyperlinked GUI.
C
43
star
18

bdalias

Simple Cocoa wrapper for Carbon Aliases
Objective-C
38
star
19

Blitz

20 slides. 15 seconds each. 5 minutes total. Go.
Objective-C
32
star
20

JRTruthTable

tell it the current conditions, and it will tell you the current state
Objective-C
31
star
21

node-mysql-oil

slick api on top of node-mysql
JavaScript
30
star
22

clonedrive

paranoid bytewise drive cloning
C
26
star
23

JRLog

Simple but flexible Log4J-like logging system for Objective-C
Objective-C
26
star
24

SafeToUnplug

tiny faceless background app that notfies you when it's actually safe to unplug a drive
Objective-C
22
star
25

ForceQuitUnresponsiveApps

Small background app for Mac OS X 10.6+ that automatically force-quits hung apps
C
22
star
26

BlockStep

makes async code (Obj-C+Blocks) read kinda like sync code
Objective-C
21
star
27

NSKeyedArchiver-butWithNSError

Categories to make NSKeyedArchiver & NSKeyedUnarchiver easier to use and report errors via NSError**
Objective-C
19
star
28

CodaAutosaveOnDeactivate

Coda plugin to automatically save edited documents upon application focus resignation
C
19
star
29

nginx-homebrew-support

support files for nginx-homebrew running as a machine-wide service
Ruby
15
star
30

OpenRadarApp

client-side app for automatically posting Apple-filed RADARs to OpenRadar
JavaScript
14
star
31

webedit

think TextEdit but using WebKit
Objective-C
13
star
32

hypo

why just #import a header file when you can import the object itself?
Objective-C
12
star
33

JRKVOBlocks

Another take on integrating KVO with Blocks. 10.6+manual memory management assumed
Objective-C
12
star
34

ComplimentKit

opt-in to automatically receive flattrs (microdonations) as your users use your mac app
12
star
35

UIView-jr_addConstraints

easier notation for adding Auto Layout constraints to UIView
Objective-C
11
star
36

CoreData-JRExtensions

Objective-C
10
star
37

JRPDFLabel

Design your interface in Interface Builder using custom fonts without having to bundle them
Objective-C
9
star
38

NSXReturnThrowError

Adds origin information to NSError and eases wrapping error codes
Objective-C
9
star
39

Transformation-Matrix-Funhouse

demo of -webkit-transform: matrix3d() (and transformation matrices in general)
JavaScript
9
star
40

JSRegexTeststand

simple single-page app to dynamically develop and test javascript regular expressions
HTML
9
star
41

jryaml

Modern YAML for ObjC. Uses libyaml and Mike Schrag's MDYAML
8
star
42

woplat

WOInstaller + Wonder Web Server Adaptor + OS Support Files
C
8
star
43

unpopular

Chrome Extension that hides indicators of social status on GitHub (watchers, stars, forks) and Twitter (followers, retweets, favs)
CSS
8
star
44

UIView-jr_viewInSuperview

Let's make it easier to create an Auto Layout-ed UIView
Objective-C
7
star
45

MiscMerge

textual templates for Obj-C
Objective-C
6
star
46

BillingsCal

Simple comprehensive live reporting of Billings' database
Objective-C
6
star
47

TwitterReflectorDish

a simple twitter reflector dish (used for @c4)
6
star
48

Function.introspect.js

Small javascript library that interrogates a function to return its name, argument names and source code
JavaScript
6
star
49

ply

minimalist CSS library
5
star
50

xib2pdflabels

tool that generates a multipage PDF, one page per JRPDFLabel view
Objective-C
5
star
51

atomicity

Blast from the Classic Mac OS past. Atomic Locks, Stacks, Guarded Stacks, Queues, and Guarded Queues
C
5
star
52

JRCenteringScrollView

UIScrollView subclass that uses Auto Layout to center its content
Objective-C
5
star
53

slowgold

minimal osx app launcher/switcher
Objective-C
4
star
54

docker-webobjects

WebObjects under Docker. Dead can dance.
4
star
55

catchr

es6 const assignment even with exceptional code
JavaScript
4
star
56

git-import-commit

like git-cherry-pick, but with more sledgehammer
C
4
star
57

CALayer-jr_UIColor

Easily get+set CALayer background and border colors as UIColors in an ARC-safe fashion.
Objective-C
4
star
58

pomodoro

fork of http://github.com/ugol/pomodoro
C
4
star
59

rentzsch.tumblr.com-theme

Tumblr theme used by rentzsch.tumblr.com + MarsEdit
3
star
60

nsxmlelement-elementwithxmlformat

Easier ObjC XML generation
Objective-C
3
star
61

burndeck

SIMBL plugin that adds CD burning to http://www.tapedeckapp.com
Objective-C
3
star
62

simplest-multiplexed-framing-protocol

simple binary protocol for concurrent async unix sockets
C
3
star
63

jsongo

like mongo db, except stores data in git-friendly flat json files
TypeScript
3
star
64

JRLogDemo

Simple app demonstrating JRLog
Objective-C
3
star
65

docker-webobjects-wotaskd

WebObjects' wotaskd in handy container form
3
star
66

qunit

would be a fork of http://github.com/jquery/qunit if that actually held anything
JavaScript
3
star
67

access-date

AppleScript Addition (osax) to retrieve a file's last access date
C
2
star
68

Saw

External-process output destination for JRLog
Objective-C
2
star
69

CoreEndian-RuntimeTarget

Header file with macros for targeting specific endian targets with CoreEndian
C
2
star
70

ReactiveCocoaExample1

Objective-C
2
star
71

dbslayer

unofficial github clone of official dbslayer svn repo
JavaScript
2
star
72

node-arq

node.js implementation of arq backup
2
star
73

jsontable

Simple, efficient, flexible, streamable tabular textual data format
TypeScript
2
star
74

mach_error-Decoder-Ring

simple+lame cocoa app that decodes mach_error integers
Objective-C
2
star
75

Math.uuid.js

fork of Robert Kieffer's Math.uuid.js in jquery.pkg format
JavaScript
2
star
76

elemental

An intrusive, fast (constant-speed), doubly-linked list in C
C
2
star
77

usc

United States Customary Unit lengths (inches, feet) calculator in JS
TypeScript
1
star
78

wiki

wolf's personal wiki
1
star
79

do-dns

command-line tool for downloading and uploading Digital Ocean DNS records
TypeScript
1
star
80

SwiftCoreDataRelationshipRepro

simple Mac app that reproduces failure to set a to-one relationship using Core Data with Swift (Xcode 6b3-4)
Swift
1
star
81

docker-apache-webobjects

Apache + WebObjects Adapter under Docker
1
star
82

giles

simple ajax frontend to DBSlayer
1
star
83

node-google-image-search-url-results

simple node frontend to google image search results (as an array of urls)
JavaScript
1
star
84

WhitelistDeliciousContentSecurityPolicy

Adds https://delicious.com to GitHub's Content-Security-Policy Header so its bookmarklet works
JavaScript
1
star
85

pretty164

Simple E.164 dash-inserter
TypeScript
1
star