Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. void EmbedWatermark(short *vals, char *msg)
  2. {
  3. int chars = NUM_CHARS;
  4. int numVals = LSBS, numChars = BITS_PER_CHAR, mask;
  5. while(chars--)
  6. {
  7. while(numChars){
  8. if(numVals <= numChars)
  9. {
  10. mask = (1<<numVals)-1;
  11. *vals = (*msg >> BITS_PER_CHAR - numChars & mask) | (*vals & ~mask);
  12.  
  13. numChars -= numVals;
  14. numVals = LSBS;
  15. vals++;
  16. }
  17. else
  18. {
  19. mask = (1<<numChars)-1;
  20. *vals = (*msg >> BITS_PER_CHAR - numChars & mask) << (numVals - numChars) | (*vals & ~((1<<numVals)-1));
  21.  
  22. numVals -= numChars;
  23. numChars = 0;
  24. }
  25. }
  26. msg++;
  27. numChars = BITS_PER_CHAR;
  28. }
  29. }
  30.  
  31.  
  32. void PrintWatermark(short *copy)
  33. {
  34. int chars = NUM_CHARS;
  35. int numChars = BITS_PER_CHAR;
  36. int numVals = LSBS;
  37. int mask;
  38. char printChar = 0;
  39. while(chars)
  40. {
  41. while(numChars != 0)
  42. {
  43. if(numChars < LSBS)
  44. {
  45. mask = (1<<numChars)-1;
  46. printChar = (*copy >> LSBS - numChars & mask) << (BITS_PER_CHAR - numChars) | printChar;
  47. numVals = LSBS - numChars;
  48. numChars = 0;
  49. }
  50. else
  51. {
  52. mask = (1<<numVals)-1;
  53. printChar = (*copy & mask) << BITS_PER_CHAR - numChars | printChar;
  54. numChars -= numVals;
  55. numVals = 3;
  56. copy++;
  57. }
  58. }
  59. printf("%c\n", printChar);
  60. printChar = 0;
  61. numChars = BITS_PER_CHAR;
  62. chars--;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement