Research Article

Data Authentication for Wireless Sensor Networks with High Detection Efficiency Based on Reversible Watermarking

Algorithm 2

Encoding
Input: original data stream S
Output: stream
while (Stream S is not over) do
1. if (spflag ==0)
2. GS1Si−1
3. .
4. for k ⟵1 to i−1 do
5. Hk ⟵ hash(Gk, d)
6.  ⟵ ( + Gk) /2
7. end for
8. H=H1H2Hm//H ={Wr, 1 ≤ rd & Wr =0||1};
9. else if (spflag ==1)
10. CS1S2Si−1
11. for j ⟵1 to i−1 do
12. Cj
13. pe'pe × 2 + Wj
14. Cj' ⟵ + pe'
15.  ⟵ ( + Cj) /2
16. if (md5(Cj') % m ==0) //Cj' is a fake synchronization point;
17. Cj' ⟵ fcb(a) + Cj' //Add fcb(a) to the flag check bit of Cj';
18. else
19. b ⟵ rand() & ba//b is a random number not equal to a;
20. Cj' ⟵ fcb(b) + Cj'
21. end if
22. Sj' ⟵ Cj'
23. end for
24. end if
25. end while