Der Auslandsgeheimdienst BND verfügt wohl über eine Auswahl von Staatstrojanern mit weiteren illegalen Fähigkeiten. Diese Software soll der Geheimdienst auch an andere Behörden weitergegeben
-
Posted to google.com
Staatstrojaner des BND mit noch mehr illegalen Features
http://www.golem.de/1110/87218.html
October 21 2011, 5:53pm | Comments »
-
Posted to google.com
Report bugs and win Kindle
http://feedproxy.google.com/~r/ContinuousBlog/~3/0L8iWHOBI0o/report-bugs-and-win-kindle
CloudBees is running a 60-days "bring me bugs" contest for the Jenkins project where you may win a Kindle and Amazon gift cards for a bug report you made during the contest period. See the linked site for details about how to enter into the drawing. Greg Moy from Electronic Arts has already won for the first week, but there are more rounds to come.
Several years ago Sun did the same thing around GlassFish, and it was useful to drive more participations into the project. Whether or not you were around the last time, don't forget to participate this time.
October 21 2011, 5:00pm | Comments »
-
Posted to google.com
Und noch ein Skype-Sargnagel: Stellt sich raus, es ...
http://blog.fefe.de/?ts=b05e9706
Shared by Carsten
Ich glaub, es ist jetzt doch langsam Zeit, den Leuten nochmal Jabber, OTR und GPG zu erklären... :-] Und noch ein Skype-Sargnagel: Stellt sich raus, es gibt sowas wie eine "stille SMS" für Skype. Man kann anrufen, ohne dass der Angerufene es merkt, und kriegt dann die IP-Adresse von dem mitgeteilt. Das Paper, das das aufdeckt, weist darauf hin, dass man so Bittorrent-Aktivität zu einem Skype-Account und damit zu einer Person zurückverfolgen kann.
October 21 2011, 7:01am | Comments »
-
Posted to google.com
Google Reader Getting Overhauled, Removing Your Friends
http://feedproxy.google.com/~r/Techcrunch/~3/NJ4pTmrEXts/
Today Google announced its long-ignored RSS app Google Reader is getting an update. Most notably, it’s getting a fresh new design along the same lines as Google’s other products, like Docs, Maps, Search and Gmail. While I’m not entirely thrilled about this change (I prefer the utilitarian look for the service), I understand Google’s need to maintain user interface consistency across its online products. What really bothers me, however, is Google’s casual decision to remove all of Google Reader’s “social” features, including friending, following and shared link blogs. Look, I get that there’s probably only ten of you out there reading this who care much about changes to Google Reader. For mainstream news consumers, that Google is now streamlining and beautifying this neglected product is probably welcome news. But for those of us who use Google Reader regularly as a utility – as a place to track, follow, archive and search dozens of sources of information from favorite blogs to company feeds and more – any change to Reader has the equivalent impact as an overhaul of Gmail. In other words, proceed carefully or prepare for an earful. And in this particular case, here comes the earful: I’m going to miss the “social” features Google Reader delivers. Wait, don’t laugh! To be clear, I don’t really consider or use Google Reader as “social” product like Facebook, Twitter or Google+ (hence the quotes). I don’t comment much on feeds, or friend and follow dozens of users. But I do enjoy reading the shares from a select group of heavy-duty RSS consumers who are consistently sharing interesting items. When I’m behind on the day’s news, all I have to do is read TechCrunch, TechMeme and this carefully constructed “human curated” list of shares. It is, and will be up until the day it disappears, one of the most regular and enjoyable news consumption behaviors I engage in every day. Although there are many other services out there that promise to bubble up relevant content based on my interests, the best product I’ve used to date was the human curation of my Google Reader friends. Not only did my group consistently share the top tech news I’d want to read, they also share those oddball but interesting stories from outside of tech, including humorous cartoons, popular videos, space and science news, parenting tips and other news completely unrelated to tech, but still compelling. Of course, there were probably only a handful of us really using this feature, so of course, like all those other services Google is shutting down, it’s getting axed too. But Google, if you think I’m going to “Circle” this group in order to continue reading their shares, you’ve got another thing coming. You can’t force me into using Google+ by stealing pieces of Google Reader. That’s not how that’s going to work.
October 20 2011, 9:38pm | Comments »
-
Posted to google.com
Official Google Reader Blog: Upcoming changes to Reader: a new look, new Google+ features, and some clean-up
http://googlereader.blogspot.com/2011/10/upcoming-changes-to-reader-new-look-new.html
October 20 2011, 7:15pm | Comments »
-
Posted to google.com
Mir hat gerade ein Vögelchen Zierckes Talking Points ...
http://blog.fefe.de/?ts=b05ed620
Mir hat gerade ein Vögelchen Zierckes Talking Points zugespielt, und bevor ich klären konnte, ob ich das veröffentlichen kann oder nicht, sehe ich, dass die Kollegen von Netzpolitik.org das schon getan haben. Sehr schön! händereib ärmelhochkrempelAlso was schreibt er denn da so.Das BKA hat keinen Verfassungsbruch begangen!Das wird sich zeigen.In unsere OLD- und Quellen-TKÜ-Software war zu keinem Zeitpunkt eine rechtswidrige Hintertür zum Aufspielen von Ausspähprogrammen eingebaut.Das klingt gut, leider wird es noch im selben Dokument auf Seite 7 der Lüge überführt:Update selbst wird mit der Updatefunktionalität der Digitask-Aufzeichnungseinheit durchgeführt (Updates werden protokolliert)Das mit dem Protokoll klingt gut, aber leider ist ein Protokoll auf Seiten des Trojaners wertlos, weil es von Dritten manipuliert werden kann, und ein Protokoll auf Seiten des BKA ist auch wertlos, weil über die Schnittstelle auch von Dritten weitere Malware hochgeladen worden sein kann, ohne dass das überhaupt beim BKA vorbeikommt.Es gibt keinen Zugriff von Dritten auf die Software des BKA.Da bin gespannt auf Ihre Beweisführung, Herr Ziercke!Die Planung, Durchführung und Nachbereitung von Quellen-TKÜ und Online-Durchsuchung folgen einem detaillierten Phasenkonzept, einschließlich ausdifferenzierter Prüf- und Kontrollmechanismen.Bei dem Satz muss jemand den Inhalt mitzuübertragen vergessen haben. Hier ist jedenfalls keiner angekommen. Auch die ganze Seite 4 ist reiner "Beweis durch Behauptung"-Kinderkram. Damit können sie vielleicht jemanden wie den Uhl überzeugen, aber sonst niemanden. Kein Wunder, dass sie das hinter verschlossenen Türen vor ausgesuchtem Publikum gehalten haben. Sonst wären sie ja aus dem Saal gelacht worden damit.Dann machen sie noch die Ansage, dass sie in Amtshilfe für Rheinland-Pfalz und Hessen Trojaner verteilt haben. Sehr schön!Desweiteren verweisen sie auf ihre ISO 9000ff-Zertifizierung (HAHAHAHA, Snake Oil zum Quadrat, das lässt ja tief blicken, dass sie DAS als Beleg für ihre Integrität nehmen!) und ein Phasenkonzept. Wer schonmal in einer WG gewohnt hat, mit Konzept zum gemeinschaftlichen Geschirrspülen und Müllrunterbringen, der wird das ähnlich erheiternd finden wie ich jetzt. Sie zitieren da ab Seite 6 das Phasenmodell. Ich kann das nicht mal pasten hier, ich hab vom Fremdschämen Rheuma gekriegt und kann die Maus nicht mehr schieben. AU DIE SCHMERZEN! Das einzige, was man da mitnehmen kann, ist dass es einen Amtsleitungsvorbehalt gibt. D.h. die Amtsleitung steht jetzt persönlich mit einem Bein im Knast und kann das nicht mehr auf inkompetente Angestellte abwälzen.Schließlich kommen dann auch noch die Ausflüchte zu dem Proxy, bzw. kommen sie gerade nicht. Da steht nur:zur Verschleierung der Q-TKÜ gegenüber dem Tatverdächtigen wird die gesamte Kommunikation der Software über mindestens zwei Proxy Server geleitetEin Schelm, wer böses dabei denkt.auf diesen Proxy Servern werden keinerlei Daten abgelegt, sondern lediglich eine Durchleitung - über nicht-deutsche Server – vorgenommenAch sooo! Das ist nur eine Durchleitung! Na dann kann da ja nichts passieren. Immerhin: Sie geben zu, dass sie durch das Ausland routen. Das macht aber nichts (Seite 11), weil:Richtig ist vielmehr, das die Daten über einen ausländischen Server lediglich verschlüsselt weitergeleitet und nicht auf dem ausländischen System gespeichert werden.Ich bewundere deren Chutzpe, ihre Pfusch-Verschleierung als "Verschlüsselung" zu bezeichnen. Oh und die scheinen noch nicht verstanden zu haben, dass man mit einem Proxy auch durchfließende Daten manipulieren kann.Ein schöner Lacher ist noch die "Beendigungsphase":Überwachungssoftware wird möglichst im Rahmen operativer Maßnahmen physikalisch gelöschtsofern mangels Zugriff auf das überwachte System physikalisches Löschen nicht realisierbar, wird auf die eingebaute Löschfunktion zurückgegriffenbei letztgenannter Alternative (sogen. Fernlöschung) besteht ein Restrisiko, dass die Software oder Teile davon zu einem späteren Zeitpunkt mit forensischen Methoden durch Dritte analysiert werdenNo shit, Sherlock! Mit forensischen Methoden durch Dritte analysiert, ja? schenkelklopfDie nächste Frage, die sich stellt, ist was es mit der "revisionssicheren Dokumentation" zu tun hat, die gestern alle CDU-Tontauben nachgebetet haben.Sämtliche durchgeführten Aktionen (Updates, Modulaktivierungen und -deaktivierungen) werden protokolliert.Des Weiteren sind dort alle gewonnenen Daten (Gespräche, Chatnachrichten, übertragene Dateien) auswertbar vorhanden.Das ist nicht gut, weil "alle gewonnenen Daten" auch den Kernbereich der privaten Lebensgestaltung betrifft und nach Vorgabe des Bundesverfassungsgerichts solche Daten sofort gelöscht werden müssen. Und überhaupt stellt sich natürlich die Frage, was auf ein Protokoll zu geben ist, dass im Fall eines Manipulationsvorwurfes vom Angeklagten selber geführt wurde. Ich sage: gar nichts. Da müsste man schon besondere Maßnahmen ergreifen, um eine Manipulation besonders schwer zu machen, z.B. per Read-Only-Ausleitung der Logdaten in einen physisch separaten Logging-Bereich, bei dem nur hinten angefügt und nichts gelöscht oder überschrieben werden kann nachträglich. Was das BKA aber darunter versteht:Das systemtechnische Protokoll ist aus der Bedienoberfläche heraus nicht manipulierbar.Die operativen Worte hier sind "aus der Bedienoberfläche heraus". Wenn jemand weiß, wie man es außerhalb der Bedienoberfläche manipuliert, ist das Scheunentor offensichtlich offen. Daher dementiert das BKA auch gleich so doll sie können (ein lauer Windhauch würde diese Argumentation wegwehen):Löschen von Protokolldaten wäre nur mit administrativem Zugang (nicht der Ermittlungsbeamte, nur der Techniker hat Zugang) auf die zugrundeliegende Datenbank und entsprechendem technischen Aufwand bei gleichzeitiger krimineller Energie möglich. Dafür gibt es keinem Fall auch nur die Spur eines Verdachts!ACH, für das BKA soll die Unschuldsvermutung gelten, wenn sie mit thermonuklearen Trojanern herumhantieren? Aber umgekehrt dürfen unsere Behörden uns trojanisieren, selbst wenn wir nachweislich überhaupt nichts angestellt haben, unter der Maßgabe der Gefahrenabwehr? Im Übrigen ist das mit dem administrativen Zugang nicht glaubwürdig. Wenn das GUI ohne Admin-Zugang in die Datenbank schreiben kann, dann kann das auch der Benutzer des GUIs. Er muss sich nur die Zugangsdaten für die Datenbank aus dem GUI rauspopeln.Und ob das BKA kriminelle Energie hat, das ist ja wohl eine Frage des Blickwinkels. Die wollen Trojaner bei den Bürgern installieren! Wenn die Russen das tun, nennt man das "Mafia" und "organisierte Kriminalität" und die Politik nimmt es als Anlass, um noch mehr Trojanereinsätze zu begründen!Aber hey, ist ja noch nicht fertig. Hier ist noch ein echtes Highlight:Falsch ist, dass das BKA eine Überwachungssoftware verwendet, die mit einer unsicheren symmetrischen Verschlüsselung arbeitet und nur in eine Kommunikationsrichtung verschlüsselt. Wir verschlüsseln in beide Richtungen!HAHAHAHAHAHAHA, das alleine ist ja schon so ein Brüller, ich lach mich kaputt. Wir verschlüsseln in beide Richtungen mit einem unsicheren symmetrischen Cipher!1!!Richtig ist, dass ein gemeinsamer Schlüssel zwischen Software und Einsatzservern vergeben wird. Dies dient der Verschlüsselung und der Authentifizierung.OH DIE SCHMERZEN! Sie bestätigen also direkt, was sie im Absatz davor noch dementiert haben. Gut, mit einem symmetrischen Schlüssel kann man sich nicht authentisieren, das weiß schon jeder Informatik-Studienabbrecher, das meinen die bestimmt nicht ernst? Doch, meinen sie!Der Kommunikationspartner kann sich ohne diesen Schlüssel nicht als gültiger Partner ausgeben.Liebes BKA. IHR LIEFERT DEN SCHLÜSSEL AUS. Der ist im Trojaner drin. Der ist nicht geheim. Und man kann mit ihm nichts authentisieren. Fragt doch mal eure Krypto-Kollegen vom BSI, die haben dem Vernehmen nach Reste von Krypto-Knowhow am Start. Wenn die nicht alle schon dem Herzinfarkt erlegen sind angesichts eurer haaresträubenden Äußerungen hier, dann werden sie euch zumindest bestätigen, wie tief euer Unwissen hier reicht. "Wir haben da auch Experten", dass ich nicht lache. Gut, helfen werden euch die BSIler nicht, das haben sie ja schon angesagt. Aber euch ist ja eh nicht zu helfen.Weiter im Text. Es fehlt ja noch der Teil, wo sie den CCC als die Bösen hinstellen. Hier ist er:Seit der Veröffentlichung der Signatur der Verschlüsselung durch den CCC könnten noch laufende Maßnahmen entdeckt werden. Das BKA hat daher in einem aktuellen Verfahren der organisierten Rauschgiftkriminalität die Maßnahme sofort abgebrochen und dies der Staatsanwaltschaft und dem anordnenden Gericht mitgeteilt. Dies ist auch den Bundesländern mitgeteilt worden.ORGANISIERTE RAUSCHGIFTKRIMINALITÄT!!1! Mit anderen Worten: noch eine Online-Apotheke.Oh, eine Sache möchte ich schon noch ansprechen:Die Quellen-TKÜ-Software ist auf das Zielsystem und die dort installierte Skypeversion ausgerichtet. Bei einem Skypeupdate muss daher auch die Quellen-TKÜ-Software angepasst werden, da ansonsten die Kommunikation nicht mehr aufgezeichnet wird.Das klingt für mich nach Unsinn. Ich behaupte, dass das auch ohne Updates geht.Das BKA behauptet weiterhin, das Verfassungsgericht habe nicht gesagt, ein Mehr an Funktionalität sei generell verboten, sondern nur dann,wenn – und darauf kommt es dem BVerfG an - die durch eine Nachladefunktion eingesetzte Software zum Ausspähen von weiteren Daten genutzt würde.Hier ist, was das Verfassungsgericht tatsächlich urteilte:Art. 10 Abs. 1 GG ist hingegen der alleinige grundrechtliche Maßstab für die Beurteilung einer Ermächtigung zu einer „Quellen-Telekommunikationsüberwachung“, wenn sich die Überwachung ausschließlich auf Daten aus einem laufenden Telekommunikationsvorgang beschränkt. Dies muss durch technische Vorkehrungen und rechtliche Vorgaben sichergestellt sein.Es geht also nicht darum, ob die nachgeladene Software tatsächlich benutzt wird, um mehr abzuhören, sondern es müssen technische und rechtliche Vorkehrungen da sein, um zu verhindern, dass das geschehen kann. Das ist hier nicht der Fall, daher handelt es sich um eine klare Verletzung des Urteils.Gegen eine bloße Aktualisierungsfunktion kann das BVerfG keine Einwände haben, weil sonst die Maßnahme an sich gefährdet wäre.Den Typen, der diese Argumentation gemacht hat, würde ich gerne hinter Gittern sehen. "Ich MUSSTE den Laden ausrauben, Euer Ehren, denn mir ist ja Fahrradfahren erlaubt, und wenn ich denen nicht ein Fahrrad gestohlen hätte, dann wäre ja die Fahrradfahr-Maßnahme an sich gefährdet gewesen!1!!" Dass solche Leute überhaupt frei rum laufen können, irritiert mich maßlos, aber dass sie auch noch für Bundesbehörden der Exekutive Statements formulieren, das schlägt dem Fass den Boden aus. Wenn ihr es unter den Vorgaben nicht hinkriegt, DANN KÖNNT IHR ES HALT NICHT MACHEN. Ganz einfach!Immerhin sehen sie auch selber ein, dass ihre Beweise da wertlos sind, und weil sie keine tatsächliche Überprüfung machen können, ...Das BKA hat am 11./12.10.2011 alle Protokolle bisheriger Quellen-TKÜ-Maßnahmen mit der DigiTask-Aufzeichnungseinheit unter Beteiligung der Beauftragten für den Datenschutz sowie für die IT-Sicherheit im BKA auf Plausibilität kontrolliert hat.Äh, auf ... Plausibilität?! So Pi mal Daumen oder wie? Geschaut, dass keine Logeinträge von Freitag nachmittag kommen, weil da die Beamten auf dem Heimweg sind? Oder wie habe ich mir das vorzustellen? Wenig überraschend haben sie nichts gefunden:Im Ergebnis konnten keine Hinweise festgestellt werden, dass im BKA eine Software eingesetzt wird, die über die rechtlich zulässigen Grenzen der Quellen-TKÜ hinausgeht und dass im Rahmen der bisher erfolgreich durchgeführten Quellen-TKÜ-Maßnahmen unzulässige Daten ausgeleitet werden.Natürlich nicht. Anhand einer "Plausibilitätsprüfung" der Logdateien kann man sowas ja auch nicht beurteilen.Auf Seite 11 gibt es dann noch die Ausrede, wieso der Proxy in den USA steht. Achtung: fest sitzen bei der Lektüre:Der Grund für diese Verschleierung ist kriminalistischer Natur. Skype selbst nimmt beim Start automatisch Kontakt mit einem Server in den USA auf. Für den versierten User sollte durch die Quellen-TKÜ- Software kein anderer Eindruck entstehen.m(Halt, einen hab ich noch. Wie das BKA prüft. Ihr sitzt hoffentlich weiterhin fest:Das BKA testet die bestellte Software mit Hilfe eines sogen. Positivtests, der der Funktionalitäten der Software und die Reaktion der vom Zielsystem eingesetzten Sicherheitssoftware (Virenscanner, Firewall) prüft. Die Maßnahme wird als einsatzfähig betrachtet, wenn die bestellten Funktionalitäten vorhanden sind, und die Sicherheitssoftware keine Warnungen produziert.Selbstverständlich sind so keinerlei Aussagen über eventuell zusätzlich vorhandene Funktionalität treffbar.Update: Oh und natürlich ist der Paragraph mit den abgebrochenen Einsätzen auch gleichzeitig das Eingeständnis, dass ihre angeblich ganz andere Version des Trojaners das selbe schlechte Protokoll einsetzt und damit so verschieden nicht sein kann.
October 20 2011, 4:53pm | Comments »
-
Posted to google.com
Going for JRuby
http://feedproxy.google.com/~r/josemotanetblog/~3/UbDk7Dn5CXY/
The company I work for uses Java for all of its projects. Based on that, I have been considering looking into JRuby and giving it a try. Every piece of advice is greatly appreciated.
Context I play the Interaction Designer role and digging deeper to Struts and Java servlets, more than just HTML/CSS/jQuery, is becoming quite the challenge. I happen to love Rails and would love to try it out. My main goals are:
Take advantage of Rails’ controllers, routes and views; Use Haml with Markdown and Sass with Compass; Take advantage of REST. Finally use Rspec and inject some proper testing and specification practices.
All of this while the rest of the team can still code the models (aka the business logic) the way they prefer. I think it’s a good cause and it’s a great opportunity to improve development happiness and systems integration. The challenge Here is a list of the things I know:
I can use RVM to quickly install and use JRuby. Gems with C extensions are a bit difficult to use inside the JVM. There are alternative gems to the ones above.
I also need to get in touch with these concepts:
Web application development in Java: .jar’s, war’s, etc. Tomcat or Glassfish as servers. Importing Java code into a Rails or Sinatra app. (optional) Using Ruby code from Java.
I guess the main question would be: Where do I start? What am I supposed to know to begin developing some sort of Rails app, using it under Tomcat or Glassfish and reusing Java code from the rest of the team? Thanks for helping me, guys!
- Tags:
- Development
October 20 2011, 2:07am | Comments »
-
Posted to google.com
Optimizing Long Lists Of Yes/No Values With JavaScript
http://www.smashingmagazine.com/2011/10/19/optimizing-long-lists-of-yesno-values-with-javascript-2/
Very frequently in Web development (and programming in general), you need to store a long list of boolean values (yes/no, true/false, checked/unchecked… you get the idea) into something that accepts only strings. Maybe it’s because you want to store them in localStorage or in a cookie, or send them through the body of an HTTP request. I’ve needed to do this countless times. The last time I stumbled on such a case wasn’t with my own code. It was when Christian Heilmann showed me his then new slide deck, with a cool feature where you could toggle the visibility of individual slides in and out of the presentation. On seeing it, I was impressed. Looking more closely, though, I realized that the checkbox states did not persist after the page reloaded. So, someone could spend a long time carefully tweaking their slides, only to accidentally hit F5 or crash their browser, and then — boom! — all their work would be lost. Christian told me that he was already working on storing the checkbox states in localStorage. Then, naturally, we endlessly debated the storage format. That debate inspired me to write this article, to explore the various approaches in depth. Using An Array We have two (reasonable) ways to model our data in an array. One is to store true/false values, like so:
[false, true, true, false, false, true, true]
The other is to store an array of 0s and 1s, like so:
[0, 1, 1, 0, 0, 1, 1]
Whichever solution we go with, we will ultimately have to convert it to a string, and then convert it back to an array when it is read. We have two ways to proceed: either with the old Array#join() (or Array#toString()) and String#split(), or with the fancier JSON.stringify() and JSON.parse(). With the JSON way, the code will be somewhat shorter, although it is the JavaScript equivalent of slicing bread with a chainsaw. The impact on performance doesn’t seem to be significant, but you’d be cutting down browser support quite a bit. The main drawback of using array-based strings is their size in bytes. If you go with the number method, you would use almost 2 bytes (or characters) per number (or, more precisely, 2N − 1, since you’d need one delimiter per number, except for the last one):
[0, 1, 1, 0, 0, 1, 1].toString().length // 13, for 7 values
So, for 512 numbers, that would be 1023 bytes (or 1 KB). If you go with the boolean method, it’s even worse:
[false, true, true, false, false, true, true].toString().length // 37, also for 7 values
That’s around 5 to 6 characters per value, so 2560 to 3072 bytes for 512 numbers (which is 2.5 to 3 KB). JSON.stringify() even wastes 2 more characters in each case, for the opening and closing brackets, but its advantage is that you get your original value types back with JSON.parse() instead of strings. Using A String Using a string saves some space, because no delimiters are involved. For example, if you go with the number approach and store strings like '01001101010111', you are essentially storing one character per value, which is 100% better than the better of the two previous approaches. You can then get the values into an array by using String#split:
'01001101010111'.split(''); // ['0','1','0','0','1','1','0','1','0','1','0','1','1','1']
Or you could just loop over the string using string.charAt(i) — or even the string indexes (string[i]), if you don’t care about older browsers. Using Bitfields Did the previous method make you think of binary numbers? It’s not just you. The concept of bitfields is quite popular in other programming languages, but not so much in JavaScript. In a nutshell, bitfields are used to pack a lot of boolean values into the bits of the boolean representation of a number. For example, if you have eight values (true, false, false, true, false, true, true, false), the number would be 10010110 in binary; so, 150 in decimal and 96 in hex. That’s 2 characters instead of 8, so 75% saved. In general, 1 digit in the hex representation corresponds to exactly 4 bits. (That’s because 16 = 24. In general, in a base2n system, you can pack n bits into every base2n digit.) So, we weren’t lucky with that 75%; it’s always that much. Thus, instead of storing that string as a string and using 1 character per value, we can be smarter and convert it to a (hex) number first. How do we do that? It’s no more than a line of code:
parseInt('10010110', 2).toString(16); // returns '96'
And how do we read it back? That’s just as simple:
parseInt('96', 16).toString(2); // returns '10010110'
From this point on, we can follow the same process as the previous method to loop over the values and do something useful with them. Can We Do Better? In fact, we can! Why convert it to a hex (base 16) number, which uses only 6 of the 26 alphabet letters? The Number#toString() method allows us to go up to base 36 (throwing a RangeError for >= 37), which effectively uses all letters in the alphabet, all the way up to z! This way, we can have a compression of up to 6 characters for 32 values, which means saving up to 81.25% compared to the plain string method! And the code is just as simple:
parseInt( '1001011000', 2).toString(36); // returns 'go' (instead of '258', which would be the hex version) parseInt('go', 36).toString(2); // returns '1001011000'
Base 64 The previous method allows us to go up only to base 36. But in modern JavaScript, we can use the methods atob() and btoa() to utilize a base 64 encoding system. That’s 64 = 26, which means we can pack 6 yes/no characters into a single character, saving us 83.3% compared to the plain string method. Let’s look at the code:
atob(parseInt('1001011000', 2)); // returns 'ëM' parseInt(btoa('ëM')).toString(2) // returns '1001011000'
For some of you, this will be enough. But I can almost hear the more inquisitive minds out there shouting, “But we have 255 symbols, we are still not using strings to their full potential!” And you’d be right. There is a reason why every time you open a binary file in a text editor, you get weird symbols mixed with numbers, uppercase letters, lowercase letters and whatnot. Every character in an ASCII string is a byte (8 bits), which means that if we use the right compression algorithm, we should be able to store 8 yes/no values in it (saving 87.5%). The problem is that JavaScript doesn’t offer a built-in way to do that, so the code becomes a bit more complicated. Packing 8 Values Into One Character You can use String.fromCharCode to get the individual characters. It accepts a numerical value of up to 65,535 and returns a character (and for values greater than that, it returns an empty string). In this case, however, we’re going to use character codes of up to 255 (8 bits). (Aside: Unicode characters are variable width, so they take up from 1 up to 4 bytes per character. Thus, if you pack your data in characters beyond the first 255, you will be consuming 2 bytes instead of 1, so you might as well have used 2 ASCII characters instead — the file size would be the same. Only if, for some reason, you have a limit that is set in number of (Unicode) characters, then using the full range might be a good idea. But in most cases, the main concern is byte size, so it’s entirely pointless.) So, we have to split our string into chunks of 8 characters in size. We can do that through .match(/.{1,8}/g). To sum up, the full solution would look like this:
function pack(/* string */ values) { var chunks = values.match(/.{1,8}/g), packed = ''; for (var i=0; i < chunks.length; i++) { packed += String.fromCharCode(parseInt(chunks[i], 2)); } return packed; }
function unpack(/* string */ packed) { var values = ''; for (var i=0; i < packed.length; i++) { values += packed.charCodeAt(i).toString(2); } return values; }
It wasn’t that hard, was it? With these few lines of code, you can pack the aforementioned 512 values into — drum roll, please — 64 characters! Quite an improvement over our original 1 KB (with the array method), isn’t it? Limitations Numbers in JavaScript have limits. For the methods discussed here that involve an intermediate state of converting to a number, the limit appears to be 1023 yes/no values, because parseInt('1111…1111', 2) returns Infinity when the number of aces is bigger than 1023. This limit does not apply to the last method, because we’re only converting blocks of bits instead of the whole thing. And, of course, it doesn’t apply to the first two methods (array and string) because they don’t involve packing the values into an integer. “I Think You Took It A Bit Too Far” This might be overkill for some cases. But it will definitely come in handy when you want to store a lot of boolean values in any limited space that can only store strings. And no optimization is overkill for things that go through the wire frequently. For example, cookies are sent on every single request, so they should be as tiny as possible. Another use case would be online multiplayer games, for which response times should be lightning-fast, otherwise the games wouldn’t be fun. And even if this kind of optimization isn’t your thing, I hope you’ve found the thought process and the code involved educational. (al) Image on front page created by Ruiwen Chua.
© Lea Verou for Smashing Magazine, 2011.
- Tags:
- Coding
October 19 2011, 10:05pm | Comments »
-
Posted to google.com
Fitbit’s iPhone App is Now Available!
http://feedproxy.google.com/~r/Fitbit/~3/myF95zXhpnY/
You can now log as you go with the new Fitbit iPhone app! Fitbitters have been talking about the power of logging food and activities when achieving and setting goals. With the new Fitbit iPhone app, the power of logging your activities and food can be carried around with you wherever you go — even when you are offline. With the ability to log your meal while you’re out, you can keep track of every meal with no hassle and nothing gets forgotten. The Fitbit iPhone app allows you to log food, water, activities, and your weight with a new, easy-to-use interface. Keep track of your last synced data while you’re out, and look back on the past 14 days of steps to compare. You’ll also be able to view your goals and see your progress with each one, including your Food Goal. The new Fitbit iPhone app is completely free, and can be downloaded by going to the app store and searching for Fitbit or by going there directly by clicking here. This is Fitbit’s first iPhone app and we’re excited to invest in creating the right tools to support all day fitness for our customers. We’ll be updating and refining the app over the next few months, including adding Ultra support to the app, so be sure to “like” us on Facebook or check out our blog for the latest news. Let us know what you think by mailing us at welovefitbit@fitbit.com, or rate the app directly at the Apple app store.
- Tags:
- Uncategorized
October 19 2011, 8:45pm | Comments »


