main.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package main
  2. import (
  3. "math/rand"
  4. "github.com/bkaradzic/go-lz4"
  5. // lz4's API matches snappy's, so we can easily see how it performs
  6. // lz4 "code.google.com/p/snappy-go/snappy"
  7. )
  8. var input = `
  9. ADVENTURE I. A SCANDAL IN BOHEMIA
  10. I.
  11. To Sherlock Holmes she is always THE woman. I have seldom heard
  12. him mention her under any other name. In his eyes she eclipses
  13. and predominates the whole of her sex. It was not that he felt
  14. any emotion akin to love for Irene Adler. All emotions, and that
  15. one particularly, were abhorrent to his cold, precise but
  16. admirably balanced mind. He was, I take it, the most perfect
  17. reasoning and observing machine that the world has seen, but as a
  18. lover he would have placed himself in a false position. He never
  19. spoke of the softer passions, save with a gibe and a sneer. They
  20. were admirable things for the observer--excellent for drawing the
  21. veil from men's motives and actions. But for the trained reasoner
  22. to admit such intrusions into his own delicate and finely
  23. adjusted temperament was to introduce a distracting factor which
  24. might throw a doubt upon all his mental results. Grit in a
  25. sensitive instrument, or a crack in one of his own high-power
  26. lenses, would not be more disturbing than a strong emotion in a
  27. nature such as his. And yet there was but one woman to him, and
  28. that woman was the late Irene Adler, of dubious and questionable
  29. memory.
  30. I had seen little of Holmes lately. My marriage had drifted us
  31. away from each other. My own complete happiness, and the
  32. home-centred interests which rise up around the man who first
  33. finds himself master of his own establishment, were sufficient to
  34. absorb all my attention, while Holmes, who loathed every form of
  35. society with his whole Bohemian soul, remained in our lodgings in
  36. Baker Street, buried among his old books, and alternating from
  37. week to week between cocaine and ambition, the drowsiness of the
  38. drug, and the fierce energy of his own keen nature. He was still,
  39. as ever, deeply attracted by the study of crime, and occupied his
  40. immense faculties and extraordinary powers of observation in
  41. following out those clues, and clearing up those mysteries which
  42. had been abandoned as hopeless by the official police. From time
  43. to time I heard some vague account of his doings: of his summons
  44. to Odessa in the case of the Trepoff murder, of his clearing up
  45. of the singular tragedy of the Atkinson brothers at Trincomalee,
  46. and finally of the mission which he had accomplished so
  47. delicately and successfully for the reigning family of Holland.
  48. Beyond these signs of his activity, however, which I merely
  49. shared with all the readers of the daily press, I knew little of
  50. my former friend and companion.
  51. `
  52. func main() {
  53. compressed, _ := lz4.Encode(nil, []byte(input))
  54. modified := make([]byte, len(compressed))
  55. for {
  56. copy(modified, compressed)
  57. for i := 0; i < 100; i++ {
  58. modified[rand.Intn(len(compressed)-4)+4] = byte(rand.Intn(256))
  59. }
  60. lz4.Decode(nil, modified)
  61. }
  62. }